Author: martin fierz
Date: 10:05:57 12/05/03
Go up one level in this thread
On December 05, 2003 at 12:34:44, F. Huber wrote: >On December 05, 2003 at 12:20:06, martin fierz wrote: > >>hi franz, >> >>i looked up in my book, and here's what it says: under windows, there are >>different memory allocation functions. one of them is HeapAlloc, which allocates >>memory from the program's heap. another is VirtualAlloc, which will get memory >>differently, sort of directly from the OS. >> >>HeapAlloc has a limitation to allocating at most 256MB under windows 98. >>VirtualAlloc has no such limitation, and HeapAlloc under win2k also has no >>limitation. >> >>i suspect that malloc translates to HeapAlloc internally under windows, and >>that's the reason for your problem. note also that uli can allocate more memory >>with malloc because the 256MB HeapAlloc limitation is only valid for win98. >> >>cheers >> martin > >Hello Martin, > >thanks for your hints - I´ll have a look at these functions. > >But what I don´t understand is: why does it work with the Borland compiler? >Also this compiler has to call Windows functions for getting memory, >and with the Borland version there´s no 256MB limit, not even under my >Windows 98, so the OS can not be the problem. > >Portability is no theme for my ChestUCI, since it´s of course only running >under Windows. > >So let´s see, if there will come some other suggestions here - >thanks again and best regards, >Franz. hi franz, i believe this might all be consistent: windows has different mem alloc functions, and the compiler translates "malloc" into one of them. so if the borland compiler translates it into "virtualalloc" while the MS compiler translates it into "heapalloc", you get exactly the kind of behavior you observed. if portability is not an issue, then you should use the windows functions. my book says you should use virtualalloc for large chunks of memory, and heapalloc for small chunks. heapalloc is supposed to be much slower when handling large amounts of memory. virtualalloc is quite easy to use, just do pointer = VirtualAlloc(0, number_of_bytes, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); to allocate memory, and VirtualFree(pointer, 0, MEM_RELEASE); to free it again. cheers martin
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.