Content deleted Content added
Citation bot (talk | contribs) Add: title. Changed bare reference to CS1/2. | Use this bot. Report bugs. | Suggested by BrownHairedGirl | #UCB_webform 803/1917 |
Citation bot (talk | contribs) Alter: title. | Use this bot. Report bugs. | Suggested by AManWithNoPlan | #UCB_CommandLine |
||
Line 369:
{{Disputed section|Most_of_the_memory_use_section_is_really_odd_nitpicks|date=August 2019}}
Java memory use is much higher than C++'s memory use because:
*There is an overhead of 8 bytes for each object and 12 bytes for each array<ref>{{Cite web|url=http://www.javamex.com/tutorials/memory/object_memory_usage.shtml|title = How to calculate the memory usage of Java objects}}</ref> in Java. If the size of an object is not a multiple of 8 bytes, it is rounded up to next multiple of 8. This means an object holding one byte field occupies 16 bytes and needs a 4-byte reference. C++ also allocates a [[Pointer (computer programming)|pointer]] (usually 4 or 8 bytes) for every object which class directly or indirectly declares [[virtual function]]s.<ref>{{cite web |url=http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=195 |title=
*Lack of address arithmetic makes creating memory-efficient containers, such as tightly spaced structures and [[XOR linked list]]s, currently impossible ([[Project Valhalla (Java language)|the OpenJDK Valhalla project]] aims to mitigate these issues, though it does not aim to introduce pointer arithmetic; this cannot be done in a garbage collected environment).
*Contrary to malloc and new, the average performance overhead of garbage collection asymptotically nears zero (more accurately, one CPU cycle) as the heap size increases.<ref>https://www.youtube.com/watch?v=M91w0SBZ-wc : Understanding Java Garbage Collection - a talk by Gil Tene at JavaOne</ref>
Line 503:
===In programming contests===
Programs in Java start slower than those in other compiled languages.<ref>{{Cite web |url=http://topcoder.com/home/tco10/2010/06/08/algorithms-problem-writing/ |title=
==See also==
|