cuitao2046 / gperftools

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

MADV_DONTNEED does not work under FreeBSD #388

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Set TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES to something small.
2. Compile something using tcmalloc on FreeBSD which allocates then frees more 
than the amount set in step 1.
3. Notice (perhaps using top) that the size of the running application does not 
decrease to approximately TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES.

What is the expected output? What do you see instead?
VM size of the running process should decrease as pages get freed back to the 
VM subsystem.

What version of the product are you using? On what operating system?
current top of tree on FreeBSD 7.3.

Please provide any additional information below.
FreeBSD does not implement MADV_DONTNEED flag for madvise(2) the same way that 
Linux does. Instead it uses MADV_FREE to indicate that pages should be 
reclaimed by the VM subsystem. Attached is a patch which correctly uses 
MADV_FREE when it is defined on BSD-type systems (OS X included).

Original issue reported on code.google.com by ldm5...@gmail.com on 5 Jan 2012 at 10:15

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the report!  I ended up fixing this in a slightly different way, but 
it should have the same effect.  I'll get this reviewed locally and then into 
svn.

Original comment by csilv...@gmail.com on 13 Jan 2012 at 6:35

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