News for hackers. Stuff that matters.
Re:Help, My Java Object Vanished (and the GC Is Not at Fault) by ErikCorry on Saturday November 29, 2025 @08:46AM (#46087500)
Nice!

Why malloc? Surely this is an on-heap object, not malloc allocated?

Re:Help, My Java Object Vanished (and the GC Is Not at Fault) by tialaramex on Monday December 01, 2025 @08:33PM (#46116203)
I 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?"
Re:Help, My Java Object Vanished (and the GC Is Not at Fault) by comex on Monday December 01, 2025 @11:17PM (#46117484)
Not when we’re talking about a JVM, which has its own heap that does not use malloc.
Re:Help, My Java Object Vanished (and the GC Is Not at Fault) by tialaramex on Tuesday December 02, 2025 @07:10AM (#46120457)
The 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...

Re:Help, My Java Object Vanished (and the GC Is Not at Fault) by pjmlp on Friday December 05, 2025 @03:08AM (#46157909)
In 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

And the list doesn't include all, e.g. PTC (https://www.ptc.com/en/products/developer-tools/perc)

[0] - https://docs.oracle.com/javase/specs/index.html

Re:Help, My Java Object Vanished (and the GC Is Not at Fault) by 1718627440 on Friday December 05, 2025 @09:00AM (#46161370)
malloc is also not a specific implementation, but a standardized interface for allocating on the heap.
Re:Help, My Java Object Vanished (and the GC Is Not at Fault) by ErikCorry on Saturday December 06, 2025 @04:00PM (#46176557)
I'm actually pretty surprised if the JVM uses malloc to allocate the heap. V8 uses mmap, never malloc.