File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Memory optimization tips needed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Memory optimization tips needed" Watch "Memory optimization tips needed" New topic

Memory optimization tips needed

landon manning
Ranch Hand

Joined: Nov 20, 2000
Posts: 47
Basic problem: My java program is using too much memory.
Does anyone have any good memory optimization tips for java?
On a related note, does anyone know the amount of memory that some of the more common Objects use? (ie. Strings, Integers, Threads)
Landon Manning
Carl Trusiak

Joined: Jun 13, 2000
Posts: 3340
Use StringBuffer to do all your String concatinations.
On the size, I can only speculate. You can use Runtime.freeMemory() before and after creating an object to help determine this information if you want.

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
subject: Memory optimization tips needed
It's not a secret anymore!