[webkit-dev] memory consumption
ppedriana at gmail.com
Wed Jul 2 14:08:07 PDT 2008
Regarding the TCMalloc being efficient with memory usage, I think that
the small block support in TCMalloc could cause that to be so, but it
still seems to me that the per-thread caches are going to necessarily
increase memory usage. So if you use TCMalloc with lots of small blocks
and a single thread then I can see how it would use less memory than
What we typically do in the gaming industry is the following:
- Shared generalized heap of classic design.
- Small block heap for all allocations < N.
This saves memory (except for pathological cases)
and leads to improvements in fragmentation patterns.
- Pack permanent allocations high in the generalized heap,
and place non-permanent allocations low. If there are
very many small blocks, then put the small block heaps
high in the generalized heap. This leads to improvements
in fragmentation patterns.
This should result in less memory usage than TCMalloc, especially in the
case of multiple threads. But it won't be as fast as TCMalloc if
multi-threading support is enabled/used. IMO, fragmentation is something
not to be underestimated, as it raises memory requirements and results
in reduced dcache efficiency (i.e. more misses).
However, once I get my owb build working I plan on directly comparing
the two approaches and producing a report for this group. If TCMalloc
performs well then that's great.
> On Jul 2, 2008, at 1:18 PM, Paul Pedriana wrote:
>> For our uses and a lot of other non-PC uses, memory is more important
>> than speed. The memory budget we are targeting is <= 10 MB for code+data
>> to display a small blank visual page that executes a 'hello world' type
> Keep in mind, it is 8MB of reserved VM address space, not 8MB of
> actual memory committed. This might be a problem on operating systems
> with no virtual memory, but many modern embedded OSes do support it.
> See Darin's message for more details.
>> I'm wondering if there is a way to control the memory/speed tradeoff.
>> The tcmalloc memory allocator makes a similar tradeoff whereby it uses
>> more memory to gain speed, whereas a non-PC application would usually
>> want to use a more traditional allocator + small block allocator.
> I don't think that is entirely accurate. We have found that with the
> new memory returning support TCMalloc often uses less memory than
> allocators where the primary goal is memory use rather than speed.
More information about the webkit-dev