Solved

Small Java program taking up absurb amount of memory!!

Posted on 2004-04-12
8
207 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
  • 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:mayankeagle
ID: 10803953
You can increase the amount of memory that the JVM uses by setting the -Xmx option while running your program.
0
 
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 30

Expert Comment

by:mayankeagle
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

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…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

708 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now