• 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

Memor Leak

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
I have writeen program which read text file and insert each records into SQL 2000. Text file has around 200,000 records. The problem i have found is it consumes lots of memory while program is running and inserting records. The memory goes up to 256MB and start decreasing and than at some stage it throws OutOfMomory Error message.
Most of my variables are Stirng and few float. Its a very simple java application, which load jdbc driver, make conncetion to data base and prepare sql statement and so on.
I thought garbage collector should run automatically when jvm reaches max to the heap size but i think gc is not able to free enough momory for the request and therefore i got outofmomory error message.
Hope some has same kind of problem and have some kind of solutions.
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds like your not cleaning up after yourself. Do you free up all temporary/local variables after use? Maybe the program is creating temporary objects(behind the scenes) which are not getting cleaned up?
by the way, on the topic of performance, are you executing each PreparedStatement separately or are you batching them? If you are not batching look into it, sounds like you could gain some real performance gains here!
jamie
If possible, post the code. It would make it easier to give better quality advice. Sounds like a small class anywho!

[This message has been edited by Jamie Robertson (edited August 22, 2001).]
 
Rashmi Trivedi
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jamie
Thank you for your reply. I solved moemory leak problem in my porgram. It was my code which was doing it. I had prepared statment in side while loop and it was causing all the problem. I took that prepared statement out side the while loop and ran the program and it worked like a dream. I would like to attach code with this response but i don't know how to attach file here.
Thank you once again for your help.
Regards,
Rashmi
 
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
You don't have to atach files (actually you can't) but you can copy and paste pieces of solutions here.
Check out the link in my signature how to do this.
Hope this helps.

------------------
SOURCE CODE should be SURROUNDED by "code" tags.
Click here for an example
 
reply
    Bookmark Topic Watch Topic
  • New Topic