3 ms·
Not necessarily. Especially not if you can program the cache (no idea if that is possible on an ARM processor). The thing is that Malloc isn't particularly sma
by tomjen3 15y ago
Not necessarily. Especially not if you can program the cache (no idea if that is possible on an ARM processor).
The thing is that Malloc isn't particularly smart about how memory is allocated so you can end up with various tangles, etc.
On the other hand if you have enough memory you can do a hole world copy which, among other things, means that allocating memory is O(1). This is better than malloc if you have short lived and small objects.
- bitwize 15y agoThat's what custom allocators in C++ are for. If your available memory is less than five times the working-set size, GC is less efficient than some sort of malloc/free perhaps with reference counting
- dpark 15y agoWhere did you get this 5x number? As for reference counting, that's rather time-expensive, and does horrible things to the cache in multi-threaded scenarios.
- bitwize 15y agoHertz and Berger's "Quantifying the Performance of Garbage Collection vs. Explicit Memory Management": http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.61.9682 http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.61.9... The reference counting would only be used in certain cases where the dynamic extent of the object is unknown. Most objects can be cleaned up with an implicit management scheme like the RAII pattern in C++.
- dpark 15y agoThanks. I'll take a look at that.