Operating System - HP-UX
1756030 Members
4611 Online
108839 Solutions
New Discussion юеВ

How to find released memory of a process ?

 
Rajesh Srivastav
New Member

How to find released memory of a process ?

It is observed that in Unix flavors, even if a process releases memory the OS doesn't return it. This can be observed using TOP command.

It is good that OS holds the memory to use for the next memory requirement but this feature is severely affecting our application. It is reaching maxdsiz limit and atlast resulting in ENOMEM error.

1. Is there anyway to forcefully tell the OS to return the released memory ?

2. Is there any tool to know how much memory has been retained by the OS which is released by the process ?
4 REPLIES 4
Mel Burslan
Honored Contributor

Re: How to find released memory of a process ?

there is ipcs and ipcrm commands that you can use to view and release shared memory segments if this is what you mean in your question. The ipcrm command is very powerful and dangerous to use unless you absolutely know what you are doing.

read the man pages for both commands and see if it suits your purpose.
________________________________
UNIX because I majored in cryptology...
James R. Ferguson
Acclaimed Contributor

Re: How to find released memory of a process ?

Hi:

> It is observed that in Unix flavors, even if a process releases memory the OS doesn't return it...

Yes, that is the idea of the "heap". The design intention is to minimize some of the overhead of memory allocation/deallocation.

> It is good that OS holds the memory to use for the next memory requirement but this feature is severely affecting our application. It is reaching maxdsiz limit and atlast resulting in ENOMEM error.

Then your application needs to be re-worked or you need to increase 'maxdsiz' or 'maxdsiz_64bit' for 32-bit or 64-bit processes, respectively.

> 1. Is there anyway to forcefully tell the OS to return the released memory ?

I don't know, but again, if your application 'free()'s 'malloc()'ed memory then that memory will be returned to the heap and will be available for a new 'malloc()' request.

> 2. Is there any tool to know how much memory has been retained by the OS which is released by the process ?

I don't know the answer to that, either.

Regards!

...JRF...

Dennis Handly
Acclaimed Contributor

Re: How to find released memory of a process ?

>if a process releases memory the OS doesn't return it.

The process isn't releasing memory. The user frees it and libc keeps it around.

>It is reaching maxdsiz limit and at last resulting in ENOMEM error.

This has nothing to do with your original statement. If you reach maxdsiz, you have a leak or heap fragmentation. Any space that you freed would be reused.

>2. Is there any tool to know how much memory has been retained by libc which is freed by the process?

You can call mallinfo(3) and print the various memory types.