aspose file tools*
The moose likes Performance and the fly likes Optimization Java Code - performance Vs memory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "Optimization Java Code - performance Vs memory" Watch "Optimization Java Code - performance Vs memory" New topic
Author

Optimization Java Code - performance Vs memory

raj varma
Greenhorn

Joined: Jan 05, 2003
Posts: 28
How do I calculate memory usage of My swing application ?
How do I optimise java code so that it gives good balance between - Memory Versus Performance.
Please give me hints .
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Typically, you start by optimizing your program for maintenance.
*Than* you observe wether you have a performance or memory problem, use a profiler to find the bottlenecks and remove them (as the system is optimized for maintainability, it shouldn't be that hard to do those local changes).


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Also, don't assume that performance and memory necessarily need to be traded against one another. There are many cases where reducing memory usage can result in improved performance. Building on Ilja's post above, I'd usually design and build for maintainability first, then memory, and then speed (if it turns out theres really a problem at that point.)


"I'm not back." - Bill Harding, Twister
Joe Cheng
Greenhorn

Joined: Feb 23, 2003
Posts: 11
>> How do I calculate memory usage of My swing application ? <<
System.gc();
Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
Note that totalMemory is how much the Java process is taking from the environment; totalMemory - freeMemory is the amount of memory that is actually being used.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Optimization Java Code - performance Vs memory