Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

If My process allocates some big memory and then deallocates, would top or gnome-system-monitor show that my memory usage of that process decreased ? or kernel will still reserve that memory for that process ?

What I see is I am deallocating memory. But I still see gnome-system-monitor displaying growing memory for my program. I don't find memory leak in my end. I want to know whether its not displaying released memory ? or there is really a memory leak at my end ?

share|improve this question
    
This depends on why the memory was allocated / what you're doing with it / whether it is actually free()'d -- If you're talking about a program written in Java or an interpreted language (Perl, Ruby, Python, etc.) there's no way of knowing what's going on under the hood... –  voretaq7 Nov 21 '12 at 23:11

1 Answer 1

up vote 1 down vote accepted

Your question seems to be based on a confusion between physical and virtual memory. Normal memory allocations never reserve physical memory -- the kernel is always free to use physical memory where it does the most good. And since virtual memory is cheap, there is no reason to care whether it stays reserved or not.

Typically, virtual memory will stay reserved, because there's no point in going to the effort to return it. Physical memory was never reserved in the first place, so there's nothing to do.

share|improve this answer
    
If you meant swap by virtual memory . No I am talking about Physical memory. –  user59088 Nov 21 '12 at 16:26
    
What I see is I am deallocating memory. But I still see gnome-system-monitor displaying growing memory for my program. I don't find memory leak in my end. I want to know whether its not displaying released memory ? or there is a memory leak in my end ? –  user59088 Nov 21 '12 at 16:28
1  
No, not swap, virtual memory -- address space. But since your talking about physical memory, the answer is very simple: The kernel is always free to change how physical memory is used, no matter what the process does. –  David Schwartz Nov 21 '12 at 16:28
    
@user59088: It's displaying virtual memory -- mere address space. The physical memory can still be moved to another process or use if necessary. The harm of a memory leak has nothing to do with wasting physical memory. So I think you're asking the wrong question. –  David Schwartz Nov 21 '12 at 16:30
    
Okay fine. so should I see that virtual memory usage to decrease immediately when my process deallocates ? –  user59088 Nov 21 '12 at 16:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.