Stack Size

Hello, I would like to ask how much in average is the stack size ?

I would like to create a simple game using SFML, and I wonder if I should allocate memory on the heap for images.
closed account (zb0S216C)
Wisely Done wrote:
"I would like to ask how much in average is the stack size ?"

Last time I checked, it's 1MB. I've seen an option somewhere in Visual Studio where you can change the default stack size.

Wisely Done wrote:
"I wonder if I should allocate memory on the heap for images."

Normally, images are quite large, even smaller ones; far too big to be placed on the stack. Your best bet is to allocated such resources on the heap.

Wazzak
Last edited on
Should I reserve like 10 MB for stack size and avoid dynamic memory allocation ?
closed account (zb0S216C)
It's possible to reserve a stack of that size, but only in Visual Studio. Besides, you're better off using the heap.
I suggest either implementing a linked-list, or allocating a pool of memory, and placing a resource inside the pool.

Wazzak
If you create a sf::Image on the stack only sizeof(sf::Image) bytes will be stored on the stack. The actual pixel data will be stored on the heap so it's probably not much to worry about.
Topic archived. No new replies allowed.