Solved

Small Java program taking up absurb amount of memory!!

Posted on 2004-04-12
8
211 Views
Last Modified: 2010-03-31
Hello.

I created a small Java application, basically a simple calculator to calculate interest.

There's only about 400 lines of code, no complex structure (only your basic types: int, long, float etc), just one JFrame and several jTextFields, but to my horror the program takes up over 20 MB of memory!!!!

Any help would be appreciated.

Thanks
0
Comment
Question by:sis5
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10803941
Hmmm, you have to start the JVM. The JVM takes up some memory. Out of the 20MB you're seeing used, your program probably doesn't take up more than 4MB. UI resources are expensive as memory has to be allocated for every pixels in a frame, plus loose stuff around it.
0
 
LVL 14

Accepted Solution

by:
Tommy Braas earned 90 total points
ID: 10803947
Right now I am running a small program of less than 100 lines of code, 11MB it has a JFrame and no buttons. There's a certain minimum footprint an application will take up. You have nothing to worry about!
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10803953
You can increase the amount of memory that the JVM uses by setting the -Xmx option while running your program.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10803971
>>  You can increase the amount of memory that the JVM uses by setting the -Xmx option while running your program.
That wasn't the question.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10803979
It was just a thought, in case he starts getting OutOfMemory errors later.
0
 
LVL 92

Assisted Solution

by:objects
objects earned 35 total points
ID: 10804011
you can use -Xms to set the initial heap size.

eg. to use a 4Mb heap use:

java -Xs4m ....
0
 
LVL 92

Expert Comment

by:objects
ID: 10934403
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10935345
=-)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question