Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Memory Problem

 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All..

I have question about the memory size taken by the java process.

We had delivered two iterations IT1 and IT2 ,

IT1 when runs it consumes only 15 MB , BUt IT2 (obviously code is more )
consumes 45MB of RAM .

The difference is huge, do you know if some compilation options can affect the memory size taken by clients appln.

Is there any way that we set some compliation arg so that memory consumtion by the IT2 takes less than 45MB

Thanks in Advance
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not clear about your requirements.

Do you means to say you have run two iteration of same program � first time it occupy 15 MB and second time 45 MB?
 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basic question i have 1 iterations code 2nd iteration code is bit more in size ...
when we run appln with ietration 1 code in memory it javaw.exe takes less MB
2nd iteration code takes more memory (javaw.exe takes more MB) than the iteration 1 's code
 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes second iteration code is more and new programmers have coded them , hence when running the appln javaw.exe is taking so much of memory
than prior iteration code apart from increasing heap memory size in complier options do we have any options
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15366
40
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How much memory a program needs, depends on what the program does; how many objects it allocates etc.

Since you didn't tell us anything about what your program does and what exactly the differences are in the code, it is impossible to give you a precise anwer.

It's easy to write a 5-line program that uses a lot of memory. The memory usage doesn't have anything to do with the size of the source code.

You'll just have to go and look at the code, or maybe use a profiler, to see why the program uses so much more memory. (A profiler is a tool that measures the execution speed and memory usage of a program while it's running).
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
apart from increasing heap memory size in complier options do we have any options


There is no magic wand you can wave and get lower memory use. More code means more objects so more runtime memory will be required.
Why are you talking about compiler options? It is runtime options that affect memory use.
Bill
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you measuring "memory use"?

I just wonder because, if you are using Windows Task Manager to do it, there is a common trap that people fall into. The Windows Task Manager column "Memory Usage" is the amount of *physical* memory used. This is not a particularly useful figure, as the Java classes and heap are in *virtual* memory. You need to look at the "VM Size" column, which is not shown in Task Manager by default, but can be added from the menu.

If you're not using Windows, or you've not made this mistake, please accept my apologies for the suggestion.
 
Joe Ess
Bartender
Posts: 9300
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by William Brogden:

Why are you talking about compiler options? It is runtime options that affect memory use.
Bill


The -g:none option of javac removes debugging information which results in smaller classes. Smaller classes means less memory displaced when loaded:

I'd think that classes aren't the bulk of memory use in any non-trivial program (object instances, especially Strings would be) so this optimization would probably have little practical effect.
 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends Thanks for your valuable replies...
later after investigating i came to know that our framework intialises the facade and Dao factory ...
as code increases i.e ( adding couple of mtds in DAO) i think it is obvious that it will takle more memory .
Is there any Runtime GC code which i can run to avoid to decrease the memory consuption will which i will run frequently
Any Idea will this work out ?.

Thanks in Advance
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are some cool tools for watching memory use. With Java5 or later you get JConsole. You can watch the various areas of memory go up and then GC. It's not a problem to see usage go near the max between GCs. It is probably a problem to see the low end of the sawtooth graph go up and up all day.

One of our guys uses an IBM tool that reads verbose GC logs and spits out a report of large object creation (over a configured threshold). That helped us find a class that was trying to log a 10meg string (!). It never got to the log because the switch was turned off for that class, but it got through message formatting which made multiple copies of the data.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly what are you worried about?

Is there some sort of hard limit to the amount of memory this app is allowed to use or is this just generalized worry about memory use getting out of control?

In any case, it is not GC code you should be looking for but memory management techniques and best practice. Let Java take care of GC for you.

You might want to take a look at the java.lang.ref package of classes for flexible object management.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic