• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

Small Java program taking up absurb amount of memory!!

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
sis5
Asked:
sis5
  • 4
  • 2
  • 2
2 Solutions
 
Tommy BraasCommented:
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
 
Tommy BraasCommented:
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
 
Mayank SAssociate Director - Product EngineeringCommented:
You can increase the amount of memory that the JVM uses by setting the -Xmx option while running your program.
0
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.

 
Tommy BraasCommented:
>>  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
 
Mayank SAssociate Director - Product EngineeringCommented:
It was just a thought, in case he starts getting OutOfMemory errors later.
0
 
objectsCommented:
you can use -Xms to set the initial heap size.

eg. to use a 4Mb heap use:

java -Xs4m ....
0
 
objectsCommented:
0
 
Tommy BraasCommented:
=-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now