Java 1.4.2 Released
peterwilm writes "Sun released Java 1.4.2 today. It includes many enhancements and changes among them the native look&feel for Win XP and GTK 2.0 as well as support for Itanium 2."
← Back to Stories (view on slashdot.org)
You know, I'm usually the first man upset when people say "Java is slow" without evidence, but I think performance improvement is a valid question of any new product. It's even more of a question when the new release actually is about performance to a degree. So... I wonder who modded you flaimbait, and why.
On topic though, I've noticed a lot of performance enhancements. If you don't load a GUI, you're program will start pretty much instantly, and will only take about 5M of RAM for a small program. GUI's will take 6M more just because. I'm sure a lot of the 6M is external to the VM and/or frame buffers.
In any case, I'm happy that my programs keep getting faster without me having to touch them. Also, now they work on the Itanium2, I can put that in the marketing material. (All with no coding/work on my part.) Sometimes, you have to really appreciate the good sides of Java.
Karma Clown
That's just one more reason why people are flocking to SWT over Swing.
1;
Garbage Collection is the enemy of NIO. You have to explicitly close everything now. And tell me why optional deterministic destruction in Java is considered a bad thing? Writing all this extra code to close stuff sucks.
New I/O (NIO)
The following changes have been made to java.nio functionality in J2SE 1.4.2.
* The finalize methods of the primitive channel classes (SocketChannel, ServerSocketChannel, etc.) have been removed (4777499). Performance testing revealed that the presence of these methods imposed a significant (factor of 100) garbage-collection penalty upon server-type applications that process thousands of new open channels per second. User code that deals in channels should be carefully written to close channels explicitly rather than rely upon the garbage collector to do so.
If your machine is swapping non-stop, it could be thrashing. If it's thrashing, then you should probably give up and buy more memory since you're basically using your hard drive as RAM at this point.
You might want to try generating the Java API docs with 'javadoc' for more VM fun.
Because java forks processes, sometimes the OS will lie about how much memory Java is actually using. Turn on the Thread count option so you can see how many threads the process has. I can run Eclipse with -Xmx4M but not 2M. When I run it with 4M, I get 30M usage in 11 threads.. 11*4=44M which would be the maximum windows could report.
If you have 11 threads, and you are using 300M, you are getting around 90% usage of a 32M heap. This means the VM has to relocate memory in order to bring up new windows, and text files you have open will be fragmented and/or garbage collected when you switch away.
Really, you should try -Xmx256M, and I bet it runs much smoother.
The default settings only lets java claim 64M of RAM last time I checked.
Isn't it funny that everyone complains about Java's memory footprint when in fact the memory usage is usually about 10% of what they think it is because Java spawns at least 4 threads, and usually 5-6. Console applications use about 5 threads and consume about 1M of RAM, but they get reported as 5M or so RAM.
By default, the OS will report each individual thread as having access to the heap, so each thread is claiming about 3M of RAM in eclipse on my computer. So, windows adds them all together (11 threads) and tells me there is 30M of RAM in use. (It will actually start with only 3M of heap on my computer, but it's slow.)
People on Linux systems add together all the VM memory usage and say Java is using 1G of RAM on my linux machine (because Java on Linux uses more RAM for some reason.) The real way to calculate the ammount of RAM in use is to take the RSS field of "ps" of the largest process (they should all be the same, but sometimes they have some handles that are just allocated to a single thread where the heap is accessable to all.).
Karma Clown