LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 08-31-2011, 07:15 AM   #1
greencacti
LQ Newbie
 
Registered: Aug 2011
Posts: 4

Rep: Reputation: Disabled
VIRT memory jumps by 64M


Our application is moving from SLES10 SP2 to SLES11 SP1. When running stability test for 4 days, VIRT of some processes can jump 64M sometimes. But Res doesn't change. I am not sure whether it is memory leak.
When I check by pmap, I find that all of increased 64M are [anon]. I can confirm our application will not alloc 64M memory one time.
 
Old 08-31-2011, 07:31 AM   #2
greencacti
LQ Newbie
 
Registered: Aug 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Pmap output when process is starting:

START SIZE RSS PSS DIRTY SWAP PERM MAPPING
0000000000400000 2548K 1112K 1112K 0K 0K r-xp /opt/***
000000000087c000 84K 52K 52K 24K 0K r--p /opt/***
0000000000891000 304K 24K 24K 12K 0K rw-p /opt/***
00000000008dd000 908K 880K 880K 880K 0K rw-p [heap]
00007f006196a000 4K 0K 0K 0K 0K ---p [anon]
00007f006196b000 8192K 12K 12K 12K 0K rwxp [anon]
00007f006216b000 4K 0K 0K 0K 0K ---p [anon]
00007f006216c000 8192K 8K 8K 8K 0K rwxp [anon]
00007f006296c000 4K 0K 0K 0K 0K ---p [anon]
00007f006296d000 8192K 8K 8K 8K 0K rwxp [anon]
00007f006316d000 4K 0K 0K 0K 0K ---p [anon]
.....................

pmap output when process is running for some time:

START SIZE RSS PSS DIRTY SWAP PERM MAPPING
0000000000400000 2548K 1112K 1112K 0K 0K r-xp /opt/***
000000000087c000 84K 52K 52K 24K 0K r--p /opt/***
0000000000891000 304K 24K 24K 12K 0K rw-p /opt/***
00000000008dd000 908K 880K 880K 880K 0K rw-p [heap]
00007f0054000000 132K 24K 24K 24K 0K rw-p [anon]
00007f0054021000 65404K 0K 0K 0K 0K ---p [anon]
00007f005c000000 132K 44K 44K 44K 0K rw-p [anon]
00007f005c021000 65404K 0K 0K 0K 0K ---p [anon]
00007f006196a000 4K 0K 0K 0K 0K ---p [anon]
00007f006196b000 8192K 12K 12K 12K 0K rwxp [anon]
00007f006216b000 4K 0K 0K 0K 0K ---p [anon]
00007f006216c000 8192K 8K 8K 8K 0K rwxp [anon]
00007f006296c000 4K 0K 0K 0K 0K ---p [anon]


It seems that some 65404 occurs
 
Old 08-31-2011, 08:02 AM   #3
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by greencacti View Post
When I check by pmap, I find that all of increased 64M are [anon]. I can confirm our application will not alloc 64M memory one time.
Allocation of anonymous memory is a two level process, and I think that is what is confusing you (and I think your application is running normally and what you have seen does not indicate a memory leak).

Library code inside your process manages a pool of free anonymous memory that has already been "committed" by Linux. When that pool doesn't have a place for the next requested chunk, the code managing the pool asks Linux to commit a large amount of additional memory, even if that next chunk is small.

That large amount of memory is just committed. It doesn't really exist. It takes up address space in your process's virtual address range. But it doesn't take any physical ram nor swap space.

Physical ram is allocated (in 4096 byte pages) only when part of that 4096 byte page is actually used.
 
1 members found this post helpful.
Old 08-31-2011, 09:34 AM   #4
greencacti
LQ Newbie
 
Registered: Aug 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
I have several more questions:
1. When starting the process, there are a lot of 8192K anonymous memory with "rwxp" perm which is seprated by 4k anonymous memory with "---p". Why does 65404k anonymous have "---p" perm? What does it mean?
2. You mentioned "When that pool doesn't have a place for the next requested chunk, the code managing the pool asks Linux to commit a large amount of additional memory". But when I run this process for 4 days, there are four 65404k anonymous occuring. If the first three 65404k anonymous memorys are used by process, this should be memory leak. But if the first three 65404k anonymous memorys are not used, why does the code managing the pool ask Linux to commit the forth 65404k anonymous memory?
3. Who and when will trigger the code managing the pool to ask linux to commit memory? The process? malloc function?
 
Old 08-31-2011, 10:11 AM   #5
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
I'm not 100% sure, but I think there is more than one memory pool in that process. Maybe malloc is keeping separate pools per thread to reduce locking requirements.

Look at a typical pair of your lines, such as
Code:
00007f0054000000 132K 24K 24K 24K 0K rw-p [anon]
00007f0054021000 65404K 0K 0K 0K 0K ---p [anon]
That indicates one of your pools did fill and the library code asked for one mapping of (65404+132)K more memory for that pool. Then six 4K pages of that were actually used and physical memory allocated.

Quote:
Why does 65404k anonymous have "---p" perm? What does it mean?
I don't quite understand the distinction (rw-p vs. ---p) between the untouched pages within the first 132K and the untouched pages in the remaining 65404K. Only 24K is allocated ram (correctly rw-p). All the rest (both inside and outside the first 132K) is just committed and wouldn't be allocated until used. So it should all be ---p. In those two lines I quoted, there ought to be only 24K of rw-p and the rest of the 132+65404 should be ---p.

I don't know whether there is a true difference in the states of the unallocated pages or whether it is just some data reduction effect in the way pmap reports things. But I'm pretty sure any difference (between the two kinds of committed unallocated pages) is not significant for your application

Quote:
If the first three 65404k anonymous memorys are used by process, this should be memory leak. But if the first three 65404k anonymous memorys are not used, why does the code managing the pool ask Linux to commit the forth 65404k anonymous memory?
None of those 65404K areas are used (yet). They are committed, not allocated. I think Linux commits the fourth of those before using the first because it has four pools inside one process (maybe four active threads).

But that 24K mentioned earlier does represent memory used later in execution when part of its pool that was enough at the beginning is no longer enough. I don't know enough about your application to estimate whether that represents a small memory leak (apparently in each of four different pools).

Last edited by johnsfine; 08-31-2011 at 10:25 AM.
 
Old 08-31-2011, 11:00 AM   #6
greencacti
LQ Newbie
 
Registered: Aug 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Let's look at the following two lines. I guess when the process create a new thread, then two more lines can occur. Tomorrow I will check it.But if my guess is correct, why does OS split two parts(4K and 8192K) for one thread? 4K is used for protecting thread overlapping ?


Quote:
Originally Posted by greencacti View Post
00007f006196a000 4K 0K 0K 0K 0K ---p [anon]
00007f006196b000 8192K 12K 12K 12K 0K rwxp [anon]
 
Old 08-31-2011, 11:11 AM   #7
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
I'm pretty sure those two lines are a thread stack (not a thread memory pool).

A no-access page is needed before each stack.
 
Old 09-02-2011, 02:10 AM   #8
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by greencacti View Post
Our application is moving from SLES10 SP2 to SLES11 SP1. When running stability test for 4 days, VIRT of some processes can jump 64M sometimes. But Res doesn't change. I am not sure whether it is memory leak.
When I check by pmap, I find that all of increased 64M are [anon]. I can confirm our application will not alloc 64M memory one time.
When application is call for malloc, malloc attempt to get memory from available memory pool and if none available call brk(2) to increase memory available for the application.
On the other hand, free just mnark memory as freed it's never return memory to the OS.

So it's quite normal that some time after the application startuo it's VIRT will increase.
But on some point application's VIRT should stabilized. If not - it's a memory leak.

You may run your application under valgrind to have a closer look on what is going with a memory.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Hacking libvirt/virsh/virt-manager/virt-install at Xen 4.0 Dom0 on top of Ubunt LXer Syndicated Linux News 0 05-06-2010 02:50 PM
LXer: Virt-install&Virt-manager at Xen 4.0-rc8 (2.6.32.10 pvops) Dom0 on top Ubuntu K LXer Syndicated Linux News 0 03-26-2010 09:41 PM
Time jumps by 1 day for an hour, then jumps back on RH 9? dieyouspammer Red Hat 3 04-07-2006 12:18 PM
10.1 on 266mhz Laptop, 64m ram, 6g h/d? Lakota Mandriva 2 02-17-2005 10:03 AM
Aopen Geforce2 Ti 64M ..please direct! thom Linux - Hardware 2 08-15-2002 11:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 07:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration