in reply to How can I free the memory of a XML::Simple-Object
The memory *is* freed. But it is freed back to the process memory pool; not back to the OS.
This is normal. Asking the OS to allocate memory to a process is an expensive operation, so once the process has requested memory, it prefers to hang onto it when one part of the program is finished with it, so that it can be reused by a later part of the program.
Think of it as memory caching. If every time you freed up a small chunk you gave it back to the OS; and then had to go back to the OS a split second later to request it back again for another part of the code; your program would run very slowly.
There are exceptions. If your program requests a particularly large single chunk of memory, that may be allocated directly from the OS rather than the process memory pool; and given back as a single chunk when your program is done with it.
But when you process an XML file into a nested data structure, the memory is not allocated all in one chunk, but rather in lots of small bits as the XML file is processed. This is done from the process memory pool, and when it is freed, it goes back to that pool.
This is why you do not see any change in the size of the process' memory allocation, when you free the XML::Simple object. But rest assured, that memory is available to the rest of the program should it require it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How can I free the memory of a XML::Simple-Object
by bulk88 (Priest) on Oct 27, 2012 at 03:28 UTC | |
by BrowserUk (Patriarch) on Oct 27, 2012 at 04:09 UTC | |
|
Re^2: How can I free the memory of a XML::Simple-Object
by Bauldric (Novice) on Oct 27, 2012 at 10:29 UTC | |
by BrowserUk (Patriarch) on Oct 27, 2012 at 11:49 UTC | |
by Bauldric (Novice) on Oct 27, 2012 at 12:34 UTC | |
by BrowserUk (Patriarch) on Oct 27, 2012 at 13:35 UTC | |
by bulk88 (Priest) on Oct 27, 2012 at 18:43 UTC | |
| |
by Anonymous Monk on Oct 27, 2012 at 10:34 UTC |