• 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

Memory leakage Problem in java/servlet

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I am struggling with a problem for the last few days.
It is a web application in which we have options for uploading data from excel,doc .. files etc to database.
The excel file may contain more than 1000 records. I am using good processor and 1GB memory.
The problem is that after doing 300 records , i can see that memory almost reaching 1GB , after that it will error like Heap error.
I know this is the problem of memory leakage.In critical parts of the program i am given System.gc() for Garbage collection.
But is not useful and also i am planning for multithreading in our program.
Please let me know any solution for this issue.

Regards,
Sanuji Pillai
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post the code section that you are suspecting it causes memory leak?
Increase VM max memory size for web server may solve the problem.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That isn't memory "leakage". That's just plain old using up all your available memory. Like Minh Nam says, one solution is to give the server more memory. (Calling System.gc() is useless -- the system will already have cleaned up all potential garbage before it crashes.)

It's also possible that your system is storing the entire file in memory unnecessarily. If you're just uploading a file and storing it into (say) a blob column in your database, it normally isn't necessary to put all of it into memory.
 
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sanuji pillai wrote:The excel file may contain more than 1000 records. I am using good processor and 1GB memory.



You need either a better algorithm, or more RAM.

These days, developers need about 4GB on a 32 bit system, and I use 8GB on all of my 64 bit systems.
Ram is cheap, get more.

But sometimes you are better off using a better algorithm. Such as reading only portions of the file at at time, rather than reading it all at once. Some files will are too big to read all at once. VIdeo files are often a couple of gigabytes each.
 
sanuji pillai
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From this i found solutions

1. Increase VM max memory size for web server or RAM.
2. Use specific algorithm for this purpose.
3. Use better processor.

Your suggestions are very precious and helpful me.

Thank You very much

Regards,
Sanuji Pillai
 
reply
    Bookmark Topic Watch Topic
  • New Topic