3 ms·
> It's crazy I can't tell Java and NodeJS "use the memory you need". Define the 'memory you need'? You know the computer doesn't have a cristal ball to know wh
by renox 10y ago
> It's crazy I can't tell Java and NodeJS "use the memory you need".
Define the 'memory you need'? You know the computer doesn't have a cristal ball to know what latency vs memory usage trade off you want..
- aianus 10y ago"Until the OS refuses to give you more" Just like every compiled, non-GC program gets. It's annoying af to fiddle with interpreter/VM "maximum heap sizes".
- munificent 10y agoAlas, "until the OS refuses to give you more" is also not a meaningful signal anymore. https://en.wikipedia.org/wiki/Memory_overcommitment https://en.wikipedia.org/wiki/Memory_overcommitment
- dikaiosune 10y agoTracing garbage collectors have to have some metric for when to trigger a stop-the-world collection. IIRC, many GCs track heap usage and trigger stop-the-world when it gets above a threshold. GC'd language runtimes which don't have a tracing/compacting collector (e.g. CPython with refcounting) don't need to configure a heap size because the behavior doesn't vary as you use up your heap.
- aianus 10y agoThat's still no good reason to throw all kinds of "Out Of Memory" errors when you're hitting 1GB out of the 16GB of physical memory on my system.
- mike_hearn 10y agoThat's what most GCs do set the default max heap size to, assuming you don't have a swap file.
- happyslobro 10y agoI wonder, could we just tell each JVM instance that it may use all of the memory on the system, and then let the OS kill the first VM that allocates more than the system has to offer? Would this get us the same semantics as those of a native application? Or does the JVM preallocate all of the memory that it is allowed to use?
- mcosta 10y agoThe JVM allocates at start a portion, takes what it needs whenever it needs until the max, but never releases memory back to the OS. So in a given moment a 6GB vm is a 5GB process but internally is using just 3GB.
- jerven 10y agoThe standard JVMs do give memory back. The standard settings are not very friendly to do so but it does work.
- mcosta 10y agoA native application on what OS?
- mike_hearn 10y agoAs of one of the most recent Java releases, I believe the G1 GC does this on Windows. G1 is not the default but can be selected with a single command line flag.