3 ms·
Nice! Why malloc? Surely this is an on-heap object, not malloc allocated?
by ErikCorry 10mo ago
Nice!
Why malloc? Surely this is an on-heap object, not malloc allocated?
- tialaramex 10mo agoI think you've got yourself confused. The heap is what malloc is allocating. So it's like you said "Surely this is somewhere in Europe, not France?" or "Surely this is a round shape, not a circle?"
- comex 10mo agoNot when we’re talking about a JVM, which has its own heap that does not use malloc.
- tialaramex 10mo agoThe JVM is of course just software. In this case it's mostly software written in C++ and that software allocates "its own heap" using uh... malloc https://github.com/openjdk/jdk/blob/master/src/hotspot/share/memory/allocation.cpp https://github.com/openjdk/jdk/blob/master/src/hotspot/share...
- pjmlp 10mo agoIn the specific case of the OpenJDK, there isn't the one JVM, rather a standard[0], like in ISO languages, with a reference implementation to go along it, https://en.wikipedia.org/wiki/List_of_Java_virtual_machines https://en.wikipedia.org/wiki/List_of_Java_virtual_machines And the list doesn't include all, e.g. PTC (https://www.ptc.com/en/products/developer-tools/perc https://www.ptc.com/en/products/developer-tools/perc) [0] - https://docs.oracle.com/javase/specs/index.html https://docs.oracle.com/javase/specs/index.html
- 1718627440 10mo agomalloc is also not a specific implementation, but a standardized interface for allocating on the heap.
- ErikCorry 10mo agoI'm actually pretty surprised if the JVM uses malloc to allocate the heap. V8 uses mmap, never malloc.