ASM can make small executables, however some MASM programs take at least 2 or 3 Mo of RAM once they are loaded under Windows NT. Is there any way to minimize the space required by an application ?
Posted on 2001-06-29 07:37:00 by karim
Two or 3 _megs_ in memory, do you mean? That shouldn't be necessary. The default sizes (for MS LINK) of StackReserve and HeapReserve in the PE header are 1 meg each, but LINK has switches /HEAP and /STACK to set these. There is some memory wastage due to SectionAlign. That needs to be 4K (one "page") except in NT, when it can be as little as 32 bytes (one cache line). LINK has a switch /ALIGN, but I haven't tried that one.
Posted on 2001-06-29 13:24:00 by Larry Hammick
Thanks Larry, I will try /HEAP and /STACK.
Posted on 2001-06-29 14:39:00 by karim
karim, The link option "/STACK:reserve[,commit]" should do what you require as long as you are not using the stack for large memory demand. I would be inclined to start with a bigger figure that you estimate and tweak it down until the app crashes with a stack fault. Interestingly enough, the nominal 1 meg stack on MASM and other EXE files rarely ever causes a problem because the limit is rarely ever reached. Regards, hutch@pbq.com.au
Posted on 2001-06-29 21:53:00 by hutch--
Karim - The biggest thing to get your head around when it comes to memory usage under windows is the virtual address space. For example, where you said the the program uses 2-3 MB of RAM, your actualy talking about virtual memory, which can be stored on your hard disk (or where ever windows feels like it). And when it comes to the reserved memory for the stack & heap, this memory range is just considered by windows to be reserved, so it wont allocate a memory block in the middle of your stack.
Posted on 2001-06-29 23:36:00 by George
OK thanks for the answers!
Posted on 2001-06-30 07:08:00 by karim