qchbai / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

HEAP_PROFILE_MMAP works wrong with malloc profile #383

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem? (A)
1. Compile the attached mmap_profile_test.cc with libtcmalloc.
2. Run it with HEAPPROFILE=??? HEAP_PROFILE_ALLOCATION_INTERVAL=1000000 
HEAP_PROFILE_MMAP=true
3. The console output will be as below.  The MB allocated cumulatively looks 
like strange.  mmap_profile_test.cc allocates only 1MB memory in one iteration. 
 It is expected to increase by 1MB.

Starting tracking the heap
Dumping heap profile to ???.0001.heap (0 MB allocated cumulatively, 0 MB 
currently in use)
Dumping heap profile to ???.0002.heap (5 MB allocated cumulatively, 1 MB 
currently in use)
Dumping heap profile to ???.0003.heap (11 MB allocated cumulatively, 2 MB 
currently in use)
Dumping heap profile to ???.0004.heap (16 MB allocated cumulatively, 3 MB 
currently in use)
Dumping heap profile to ???.0005.heap (21 MB allocated cumulatively, 4 MB 
currently in use)
Dumping heap profile to ???.0006.heap (26 MB allocated cumulatively, 5 MB 
currently in use)
Dumping heap profile to ???.0007.heap (32 MB allocated cumulatively, 6 MB 
currently in use)
Dumping heap profile to ???.0008.heap (37 MB allocated cumulatively, 7 MB 
currently in use)
Dumping heap profile to ???.0009.heap (42 MB allocated cumulatively, 8 MB 
currently in use)
Dumping heap profile to ???.0010.heap (47 MB allocated cumulatively, 9 MB 
currently in use)
Dumping heap profile to ???.0011.heap (Exiting)

What steps will reproduce the problem? (B)
1. Compile and run some program with libtcmalloc with the following check.
2. In heap-profiler.c:AddRemoveMMapDataLocked, compare mmap addresses from 
MemoryRegionMap and malloc addresses in heap-profile.
3. Some addresses may conflict.  In that case, stored malloc information will 
be broken as a result.

What version of the product are you using? On what operating system?
1.8.3 on Linux.

Please provide any additional information below.
Both issues come from merging mmap information into malloc information per 
every profile dump at bottom.

I guess the attached incomplete patch (heap-profiler.patch) would fix these 
issues.  Though it's incomplete, I wonder if you could tell me what you think 
about its rough direction.

Original issue reported on code.google.com by dmikurube@chromium.org on 6 Dec 2011 at 12:40

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by csilv...@gmail.com on 6 Dec 2011 at 9:17

GoogleCodeExporter commented 9 years ago
Updated the patch.  (Some redundant comments are included.)

Original comment by dmikurube@chromium.org on 7 Dec 2011 at 11:54

Attachments:

GoogleCodeExporter commented 9 years ago
Updated (a little) the patch.

1. The same change as http://codereview.chromium.org/8635003/ except for the 
function names of RecordAlloc and RecordAllocWithStack.
2. mmap_allocation_ may not be required in this patch.
3. Some redundant comments are included in this patch.

Original comment by dmikurube@chromium.org on 13 Dec 2011 at 4:44

Attachments:

GoogleCodeExporter commented 9 years ago
Updated. (http://codereview.chromium.org/8635003/, too)

Original comment by dmikurube@chromium.org on 13 Dec 2011 at 7:32

Attachments:

GoogleCodeExporter commented 9 years ago
Fixed some failures. (http://codereview.chromium.org/8635003/, too)

Original comment by dmikurube@chromium.org on 15 Dec 2011 at 1:04

Attachments:

GoogleCodeExporter commented 9 years ago
Updated.

Original comment by dmikurube@chromium.org on 19 Dec 2011 at 7:53

Attachments:

GoogleCodeExporter commented 9 years ago
The (most likely) final patch.

Original comment by dmikurube@chromium.org on 23 Jan 2012 at 7:15

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks!  I've got the patch ready to go with the next perftools release.

Original comment by csilv...@gmail.com on 25 Jan 2012 at 11:54

GoogleCodeExporter commented 9 years ago
This should be fixed in perftools 1.10, just released.

Original comment by csilv...@gmail.com on 31 Jan 2012 at 7:18