Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

Deallocate memory

 
Kjell Carlsson
Frequent Advisor

Deallocate memory

Hi

Is there some way to retrieve dynamic memory deallocated by a program without stopping the program. I want the working set to be decreased after the deallocate.

Regards
Kjell Carlsson
4 REPLIES
Volker Halle
Honored Contributor

Re: Deallocate memory

Kjell,

it's possible to purge the workingset of a process using DECamds / Availability Manager:

http://h71000.www7.hp.com/openvms/products/availman/6552pro_010.html#purge_fix

Volker.
Kris Clippeleyr
Honored Contributor

Re: Deallocate memory

Kjell,

There are of course the $ADJWSL, the $PURGWS and $PURGE_WS system services.

I'm not aware of a DCL command to do it from outside a program (although there is the SET WORKING_SET command).

Kris (aka Qkcl)
I'm gonna hit the highway like a battering ram on a silver-black phantom bike...
Hein van den Heuvel
Honored Contributor

Re: Deallocate memory


Kjell, your question does not compute.

Dynamic memory and workingsets have only an indirect relation.

Please be sure to spend a little time in the books reviewing virtual memory and working sets.

With 'deallocated dynamic memory' may we assume you mean malloced memory which was freed, or lib$getvm memory for which lib$freevm was called?

That memory is free for re-use by next malloc/lib$getvm, but it remains part of the address space: no SYS$DELTVA will be called for it. Of course if you do not touch again, then it is as good as gone, unless the 1GB P0 limit is a problem for your application.

Also check out VM ZONEs.

Now the working set are those virtual memory pages which can readily be addressed without a pagefault and it correspond to the physical page use for a process. If you know there are pages in the working set which not will be re-used, then you can 'help' the system by call SYS$PURGWS to tell it to go shrink now. This will avoid the system from having to look at other processes and will be more aggressive while there is no outside pressure (yet). In turn this means that the pages which were purged out, but were still in active use will tend to simply be soft-faulted back in from the free or modified list.

Hope this helps,
Hein.

Willem Grooters
Honored Contributor

Re: Deallocate memory

AFAIK, VMS will do this automatically.
If you want to be sure:

1. call LIB$CREATE_VM_ZONE (zone_id, ...)
2a. call LIB$GET_VM (zone_id, size...)
2b. call LIB$GET_VM (zone_id, size...)
...
3a. call LIB$FREE_VM (zone_id, size...)
3b. call LIB$FREE_VM (zone_id, size...)
...
4. call LIB$DELETE_VM_ZONE (Zone_id)

If you want to free all memory in this zone at once, you don't need to deallocate each allocated chunk apart, so omit step 3. Step 4 will do it automatically.

There are a few variants of these routines, check http://h71000.www7.hp.com/doc/82final/5932/5932pro.html
Willem Grooters
OpenVMS Developer & System Manager