Is it possible to set the initial heap size using GoLink? (I am using 0.26.14)

Started by sysfce2, January 07, 2010, 04:50:12 AM

Previous topic - Next topic

sysfce2

Does GoLink have a similar option to /stacksize and /stackinit to set the initial heap size?

donkey

Not that I know of, but there is no reason that it shouldn't be available, SizeOfHeapReserve and SizeOfHeapCommit are both fields in the PE specification, not sure whether they are ignored by the loader though.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

jorgon

Hi sysfce2

This can't be done at present but as Donkey says, these are fields in the PE file.

In modern Win32 and Win64 programming would it be useful to be able to adjust the usual default in the fields of 1M reserve and 4K commit?

Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)

ecube

hi jorgan
for me, it's been useful when using static libraries in asm written from C++, sometimes they complain about the stack, and that switch he was talking about above helps fix it.

sysfce2

Well, I was reading MSDN - Managing Heap Memory in Win32 and from what I gather, changing the values can speed application loading.  The PE header value indicates how much heap memory the application expects to use, so that windows doesn't have to continually resize the heap as memory is allocated.

I just thought that I would play with it to see the results - I was going to write a program that simply writes the value to the Pe header, but I figured it would be easier (for me anyway) if the linker did it.

I don't know how applicable it is the latest windows, but I use an old computer, so I was hoping that it would help.

donkey

Hi Jeremy,

Outside of my little PE viewer snippet I have never concerned myself with the fields, however I can see applications for it. For example if you plan to use the heap for a large array it would be faster if you set a larger heap size at startup. Ofcourse in most cases VirtualAlloc is a better choice than the heap for large allocations of this type but...
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable