| Author |
Optimization Java Code - performance Vs memory
|
raj varma
Greenhorn
Joined: Jan 05, 2003
Posts: 29
|
|
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: 18652
|
|
|
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.
|
 |
 |
|
|
subject: Optimization Java Code - performance Vs memory
|
|
|