Solved

Small Java program taking up absurb amount of memory!!

Posted on 2004-04-12
8
214 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

734 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