memory not falling

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

memory not falling

#1 Post by Ed Dyreen » 16 Apr 2015 08:54

When I define macro's and push them over endlocal memory increases well over 100MB. When I then undefine them, memory usage is not falling according to taskmgr. As if the gaps where data used to be are being preserved. This is a huge penalty on performance. Yet when I use 'call' to load the exact same macro's from a memoryFileDump. Only 3MB of memory is required to load them ( not pushing over endlocal ). I would expect that if I set a variable and unset it, memory is being released but this seems not to be the case. I find this very odd. It can't be that I got the number of endlocals wrong because the file that loads the macro's is different from the file that calls it. If I had the number of endlocals wrong, the variables wouldn't persist in the global caller environment and would be lost when encountering 'exit /B'.

Aacini
Expert
Posts: 1932
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: memory not falling

#2 Post by Aacini » 16 Apr 2015 09:56

Yes. This behavior is the base of my method to minimize the performance problems of SET command caused by a very large environment:

Aacini wrote:
  • When a new variable is defined with a value that exceed the current environment size, the environment is copied to a new area if the area beyond it is not available.
  • The new area is just large enough to receive the new variable. No additional space is reserved.
  • The important one: When a large variable is deleted, the remaining free space is NOT released. The environment memory block is never shrunk.

. . .

... I added the results of previous program:

Code: Select all

Initial environment                Origin=004B30, Size=000450
After defined a 4KB variable       Origin=00D740, Size=001370
After defined a 8KB variable       Origin=00D740, Size=002360
After defined two 8KB variables    Origin=00D740, Size=004360
Z2 deleted, there is one 8KB's     Origin=00D740, Size=004360
After defined Z2 again: two 8KB's  Origin=00D740, Size=004360
After defined three 8KB variables  Origin=00D740, Size=006360
Z3 deleted, there is two 8KB's     Origin=00D740, Size=006360
Z2 deleted, there is one 8KB's     Origin=00D740, Size=006360


Antonio

Post Reply