This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Performance and the fly likes Memor Leak Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "Memor Leak " Watch "Memor Leak " New topic
Author

Memor Leak

Rashmi Trivedi
Ranch Hand

Joined: Aug 13, 2001
Posts: 60
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.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

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

Joined: Aug 13, 2001
Posts: 60
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
John Bateman
Ranch Hand

Joined: Mar 09, 2000
Posts: 320
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


SOURCE CODE should be SURROUNDED by "code" tags.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Memor Leak
 
Similar Threads
Struts 2 : Validation problem with dropdown box.
does this sound good/okay/terrible?
SAXParseException: An invalid XML character (Unicode: 0x1c) was found in the XML response
is there ipc in java
ipc problems