• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

Optimization Java Code - performance Vs memory

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 .
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.)
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>> 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.
reply
    Bookmark Topic Watch Topic
  • New Topic