Java Application running SLOW on Mac

Started by
6 comments, last by igni ferroque 19 years, 4 months ago
Hello, I am new to the Macintosh environment and was wondering if someone could help me here. I have written a java application (stand-alone) on a Windows platform. The application is computation intensive and uses Java3D APIs to render 3D objects. Also, the application uses JSci APIs to render 2D graphs and has a number of other features, which use extremely large arrays. The application is built using Swing APIs whereever possible. Now, when I run the application (jar) on a Windows platform (XP), it runs fine as expected. However, when I run the same application on Mac OS X (10.3.5), it runs extremely slow, takes ages to render 3D objects or to do anything as a matter a fact. In summary, the application runs much much faster on Windows (Intel P4 - 1.4 GHz, 768MB RAM) as compared to running it on a Dual 1.42 GHz PowerPC G4 with 1GB RAM. This does not make sense to me. Any insight/help would be highly appreciated. Thanks in advance.
Advertisement
Ok... chances are your problem is GPU bound in the sense that the bottlenecks are in your display logic.

Check the state of Java3D's support for Mac hardware accelerated 3d graphics...

If this is causing you grief... it might be better to use JOGL - a java to openGL binding... ogl is a little more "primative" thatn Java3D, but because it is a bindings layer... you can be guaranteed that it's trying ot use hardware acceleration. Java3D tries to do some magic... whereby it will use acceleration IF IT detects there is a suitable platform. Otherwise, it will just do it in software, and that's where the slowdowns start. Generic microprocessors (x86 hardware) just doesn't cut it for realtime 3d graphics... hence the need for GPUs.

Java can be made to run pretty fast... the hotspot optimising jvms really do a pretty good job to cache machine generated instructions rather than interpret them. It will never be as fast as native C/C++ but the productivity gains are there... so if saeenali is doing something scientific or other where you're looking at algorithms and how they work rather than optimising for a specific game, Java would make sense.

One other thing... Swing is a very slow GUI platform. Consider using jogl to render out your graphs and what not. Alternatively, consider the framework from eclipse.
In my experience the performance of a Java app does depend pretty heavily on the JVM it's running on. Have you installed all available updates for the Mac JVM?

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Quote:Original post by philvaira
When/where is Java considered fast?


Since about 4 or 5 years ago in places where people actually know what they are talking about.

Quote:Original post by saeenali
Any insight/help would be highly appreciated.


It could very well be that the Java3D mac implementation is broken. I suggest you check out Xith3D. See if the demos run on that Mac system. If so, you might consider using it rather than Java3D. It's a Java3D-like scenegraph engine that is geared toward games. Also check out jME (another scenegraph API based on David Eberly's work). And in the future you might consider posting Java questions at the javagaming.org forums where you can avoid the ignorant trolls. There's a section there specifically for Java3D.
Have you tried poking around at it with a profiling tool? Can you tell whether or not it's getting an accelerated context?

Quote:One other thing... Swing is a very slow GUI platform. Consider using jogl to render out your graphs and what not. Alternatively, consider the framework from eclipse.
It is also likely true that Apple's Aqua Look-and-Feel is slower than other implementations. This document has instructions for changing the LAF on MacOS X.
Free Mac Mini (I know, I'm a tool)
When your app starts up, check the OS. If it's OSX, turn off your double buffering code!

Aqua automatically double buffers all windows, effectively giving you triple buffering if you have your own double buffer code.

I don't know if this is the source of your problem, but it's something to be aware of.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Quote:Original post by superpig
In my experience the performance of a Java app does depend pretty heavily on the JVM it's running on. Have you installed all available updates for the Mac JVM?


Yeah check for JVM updates. I wrote a small pong like game a few months ago and when sun updated to 1.5 the game runs unplayably fast. Remember kids, if you make your update events frame-dependent instead of time-dependent like you're supposd to, instead of bringing you toys Santa will shoot you. :P
Without order nothing can exist - without chaos nothing can evolve.
Apple Software Update usually catches JVM updates. There's no Java 5 for Mac yet... I think Apple's holding out on us until Tiger (haha). 1.4.3 seems plenty fast on my computer, but Java 5 is pretty quick on my 440Mhz UltraSPARC II.
Free Mac Mini (I know, I'm a tool)

This topic is closed to new replies.

Advertisement