• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Pruebas Online
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

126
Vistas
Allocating large buffers on the stack

Is it just a "bad manner" to allocate large buffers in a stack (if the stack has enough capacity)? I mean allocating 300-500 KB objects with an 8 MB stack in Linux systems. Or it may cause any errors? Also, are there any guidelines on how to use stack memory?

about 3 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

There's no hard rule regarding the size of stack-allocated variables.

As a general rule, I prefer to not have any stack allocations larger than about 10KB. That way running out of stack space will be much less likely to be an issue. Anything bigger than that should be dynamically allocated, then freed when no longer needed.

about 3 years ago · Santiago Trujillo Denunciar

0

Yes, it's a bad manner. Objects of that size is to be dynamic allocated (or be static). No exceptions.

What if your program one day is to be used on a system with less default stack size? For instance windows.. then you "eat" half the stack in a single call.

about 3 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda