Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Small Java program taking up absurb amount of memory!!

Posted on 2004-04-12
8
Medium Priority
?
217 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 270 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
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
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 105 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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Suggested Courses

661 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