cuitao2046 / gperftools

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

TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES doesn't affect tcmalloc behavior (was: in tcmalloc, how tcmalloc_max_total_thread_cache_bytes influence the runtime behavior of tcmalloc ?) #585

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. export TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES=1000000000
2. run program A with -ltcmalloc
3. check memory used by program A

ps: A is a multithread program(with 80+ threads) which alloc/free memory 
repeatedly

What is the expected output? 
program A eat 1G memory
What do you see instead?
program A eat 32M

What version of the product are you using? On what operating system?
gperf 2.0/2.1 REDHET

I check the source of tcmalloc, 
DEFINE_int64(tcmalloc_max_total_thread_cache_bytes,
             EnvToInt64("TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES",
                        kDefaultOverallThreadCacheSize),
             "Bound on the total amount of bytes allocated to "
             "thread caches. This bound is not strict, so it is possible "
             "for the cache to go over this bound in certain circumstances. "
             "Maximum value of this flag is capped to 1 GB.");
the tcmalloc_max_total_thread_cache_bytes will be set as value from 
'TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES' or kDefaultOverallThreadCacheSize by 
default, however, I grep tcmalloc_max_total_thread_cache_bytes  in all source 
code tree, cannot find how tcmalloc_max_total_thread_cache_bytes  was used to 
influence the behavior of tcmalloc ? can any one tell me the logic of runtime 
memory control ?
thank you very much.

Original issue reported on code.google.com by shiqu...@gmail.com on 4 Nov 2013 at 1:51

GoogleCodeExporter commented 9 years ago
Indeed appears to be a bug in the code.

There's alternative which is calling SetProperty with argument 
"tcmalloc.max_total_thread_cache_bytes".

Original comment by alkondratenko on 9 Nov 2013 at 8:40

GoogleCodeExporter commented 9 years ago

Original comment by alkondratenko on 9 Nov 2013 at 8:40

GoogleCodeExporter commented 9 years ago
Please test attached patch

Original comment by alkondratenko on 9 Nov 2013 at 10:21

Attachments:

GoogleCodeExporter commented 9 years ago
Verified and merged fix above. Thanks for raising it.

Original comment by alkondratenko on 16 Nov 2013 at 9:15