Gneneral windows apps

Windows specific forum
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.

Hi,

Can someone tell me whether the stack size for an application running under Windows is fixed (i.e. it has a maximum size limited by some value rather than available memory) or whether it is dynamic?

If it is fixed, is there any easy way to set it? There doesn't seem to be from the Windows Explorer UI so I'm guessing I'd need some tool (the languages I'm familiar with allow you to set this in the project options).

I've got some code here that runs through and has a few nested procedures. The code works fine in a small application (with not so much nesting) but crashes on a procedure call in a bigger application (I have a debug immediately before the call and one first line inside the procedure and it only ever displays the first debug before crashing).

Thanks.


--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + all updates, PB3.50)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by TheBeck.

As far as I know the linker sets the stack size. I think that is why a 4KB program will take up 2MB of RAM. I know of no way to set the stack in PB. But no, the stack is not dynamic, it starts at the top of your APP's allocated memory and works it's way down. Fred do you know more about this?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

Yes, it's fixed by the linked, and according to the LccLnk docs: 'The default stack reserves 1MB of stack space, and commits 4096 bytes of it.'.

You have to now than Windows uses a smart way to handle memory, by using hardware MMU to handle used memory. You can for example allocate 100 Mb of mem and use only 1 Mb for start, then only 1 Mb will be used. When a write operation is done on an unallocated page, then it allocates it.

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
Originally posted by fred

Yes, it's fixed by the linked, and according to the LccLnk docs: 'The default stack reserves 1MB of stack space, and commits 4096 bytes of it.'.
OK, so it is dynamic up to 1MB (default using PB), assuming I have enough physical memory to allocate another page from? I don't think I would have used 1MB from the stack, and I'm pretty sure I have free memory.

Thanks for the info!

Update: I was working on it last night and it all seems to work OK, with exactly the same code I was using before posting this. Perhaps I have some underlying hardware problem like a broken RAM module.

--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + all updates, PB3.51)
Post Reply