5 ms·
Building Memory-efficient Java Applications
- dikanggu 15y agoCool! Very good explanations.
- DanielRibeiro 15y agoVery nice presentation. However much of this can be actually discovered and felt first hand just by playing with profilers that support memory profiling (such as yourkit[1]). After a few hours playing with it, you will never forget the precious lessons on this presentation. [1] http://www.yourkit.com/ http://www.yourkit.com/
- jesperhh 15y agoDoes anyone know of a similar study of memory efficiency in C# (or the CLR in general)?
- morsch 15y agoTreeMap<Double, Double>, 100 entries, 8.6 kB, 82% overhead Man, that's just annoying.
- NSMeta 15y agoThis is probably an 'apple and oranges' type of question, but I haven't used Erlang, nor Java to build large applications. Does anyone know how Erlang compares to Java in regards to memory usage/performance?
- abecedarius 15y agoPer-object overhead is generally more reasonable.
- thesz 15y agoYou can have a whole Erlang process for a price of (roughly) 100 Java objects.
- jamii 15y agoPer object overhead in functional languages is usually lower since polymorphism is handled at the function level rather than the data level. You don't have to store class pointers etc, just the raw data and probably a type tag. I can't find a reference for erlang's representation but I believe it has only a little more overhead than ocaml which is described here - http://rwmj.wordpress.com/2009/08/04/ocaml-internals/ http://rwmj.wordpress.com/2009/08/04/ocaml-internals/
- NSMeta 15y agoI know I should thank you by up voting. But also, just want to say that the guide was a very interesting and insightful read.
- gtani 15y agousing their official docs http://erlang.org/doc/efficiency_guide/advanced.html#9 http://erlang.org/doc/efficiency_guide/advanced.html#9 (I haven't tried this: erts_debug:flat_size(dict:new()). http://stackoverflow.com/questions/1964015/erlang-what-is-most-wrong-with-this-trie-implementation http://stackoverflow.com/questions/1964015/erlang-what-is-mo...
- insom 15y agoIt just goes to show that whatever language you use, you need to understand what the abstractions are doing: what bytes are really going where?
- sjwright 15y agoThat's great, but perhaps they should teach some of this to their colleagues at IBM first.
- gtani 15y agofrom 2008. slide 25: experiments on a sampling of different JVMs. More recent : http://vanillajava.blogspot.com/2011/07/java-getting-size-of-object.html http://vanillajava.blogspot.com/2011/07/java-getting-size-of... http://vanillajava.blogspot.com/2011/07/java-how-much-memory-do-different.html http://vanillajava.blogspot.com/2011/07/java-how-much-memory... http://kohlerm.blogspot.com/2008/10/knowledge-about-much-memory-things-need.html http://kohlerm.blogspot.com/2008/10/knowledge-about-much-mem... http://kohlerm.blogspot.com/2009/02/how-to-really-measure-memory-usage-of.html http://kohlerm.blogspot.com/2009/02/how-to-really-measure-me... http://marxsoftware.blogspot.com/2011/12/estimating-java-object-sizes-with.html http://marxsoftware.blogspot.com/2011/12/estimating-java-obj... (i have zillions bookmarks on this)
- dasmoth 15y agoSome (not all) of these cases would be helped massively if the JVM gained an equivalent of the fixnum/flonum types from the LISP world. This has been proposed kind-of seriously in the past, e.g.: http://blogs.oracle.com/jrose/entry/fixnums_in_the_vm http://blogs.oracle.com/jrose/entry/fixnums_in_the_vm Has anyone seen anything more recent?
- joshhart 15y agoFor those of you who may not be familiar with them, using http://fastutil.dsi.unimi.it/ http://fastutil.dsi.unimi.it/ collections instead of Java collections is essentially the work-around for most things you'll use. Fastutil has custom classes that remove the pointer overhead associated with storing primitives. Unfortunately, Java really falls apart at the primitives aren't objects thing when it comes to performance.