• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

OutOfMemoryError

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I made a java programe for reading the files(*.pdb) of the molecule structures and displaying their graphics, but when the files of the molecule structure are little bit bigger or after loading several files, there will be a "OurOfMemoryError", what will be the possible reason for this error? Should I use finallize() method to solve this problem? And how?
 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you reading the entire file in at once? If you are then you need to find a way to only load part of the file, do something with it then close that part and continue loading the file.
If you are opening many files can you open a file, do whatever you need then close the file back?
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
x xr
Welcome to the Java Ranch, we hope you�ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can increase max memory for your process:
For example:
java -Xmx200Mb <your program>
 
travis xie
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ibrahim Hashimi
Yeah, I read the entire file in at once, but I don't think the length of the file is the reason, because I defined many vector to store the atoms and bonds of the molecule, and the error came out even if the file is only 200KB.
And when reading files, the fact is I read one file, display it, and then close the file and read another, the files won't be read together.
Anyway, I'd like to try to read only part of the file in at once.
 
travis xie
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Igor Ko
How to increase the max memory in the programe? The programe is a Applet to be showed on a website.
 
Igor Ko
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Applet ... it's problem.
If client use Sun Plug-In, you can chage it
Go to control panel/java plug-in/advanced/
jre parameter, insert -Xmx<some number>Mb.
Probably it help. (?)
But you don't know what kind of java use each user
of your site, and can't ask them all change
setting, or worse download sun java plug-in.
(It's reason that C# can be popular sometime,
because it will be preloaded in all computers with Windows )
[ November 03, 2002: Message edited by: Igor Ko ]
 
travis xie
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, it still doesn't work,even if I use the -Xmx200Mb method.
Every time I open a new file, the memory used keeps going on, the resourses the old file used doesn't seem to release!
How can I release these Vectors defined before! I've tried all kinds of ways, such as removeAllElements, System.gc() ......
None of them work! Help me!
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you setting the Vectors to null after each file has been displayed so they can be gc'd? Are you using large arrays to store things?
 
travis xie
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did set Vectors null, but the memory still doesn't decrease
 
Igor Ko
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, if Mxm doesn't help, it's much simpler.
Normal memory leak bug.
OptimazeIt can you help detect were it is.
(if you don't have it, you can download trial
version).
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Travis,
It may help if you post a code snippet... there are potentially many reasons for an OutOfMemory error - off hand, I would check specifically what you are doing in for and while loops.
Biju
 
travis xie
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, Igor, Thank u for ur sugggestion, I've download the trial version of the OptimazeIt, and i'm learning how to use it.
And, Biju, the code is a little bit large, so I can send it to u if u like
 
Igor Ko
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Travis !
I happy to hear that you use OptimazeIt,
I found my memory leaks with the pover tool.
(and also find hot spots in my program, now
it works 30-40% faster after optimization)
Does it help you ?
 
travis xie
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used the OptimizeIt to see the programe, finding that 'object[]' and 'Point3d' are the first two classes waste much memory, but I even can't find where the object[] is, and becase Point3d is used by 'BranchGroup','TransformGroup' and so on in Java3D, I don't know how to free these memory.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic