Solved

Small Java program taking up absurb amount of memory!!

Posted on 2004-04-12
8
210 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: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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Chrome and Firefox Java 5 51
servlet and mdb, jms error 1 37
Delphi Firemonkey: if the Sms contain special characters it won't send it 3 44
Setup GlassFish 4 22
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
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 will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

832 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