• 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

Servlets, and garbadge collection

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
I was wondering if anyone could help me. There is a servlet that creates employee's and stores their details, working hrs, address, payment details etc in a database.
When the servelt was tested to handle 20 users concurrently accessing it, it fell over after about 10 users, because it did not have enought memory. I am still new in the servlet business so I am not sure if I understod the problem properly, but as far as I know the problem is that too many objects were created which caused the garbage collector to go absolutely mad trying to reclaim memory in the background. So now I was asked to come up with a solution to replace statments like Employee emp = new Employee(session, ....).
Can anyone suggest an easy and quick solution ? THanks for anybodies help.
K
 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kinga
Have you tried using database connection pooling.
regards
sanj
 
Kinga Cserveny
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes but the problem is not just the database connection, I have an object (Employee) which consists of many other objects inside it. Such as PayDetails object, TimeSheet object, WorkignHrs object etc. Which causes too much memory being allocated when a new Object is created, and the garbage collects struggels to reclaim all the memory not being used. Can you suggest anything insted of using new Object()?
thanks K
 
sanj singh
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kinga
Are you storing anything in the session.If you are doing that and there are a large number of users logged in then it will bring down your application on its knees.
regards
sanj
 
Kinga Cserveny
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I am. So what can I do instead of storing it in the session? What is the problem with storing things in the session?
k
 
sanj singh
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kinga
Here's an example.Say for example each user uses 5 kb of memory then for a million users that amounts to 5 Gbs of memory.
Need i say more.
regards
sanj
 
Kinga Cserveny
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No.. I get the picture, so what can I do instead of storing them in the session, as I need to store data from everypage before eveluating them and storing them in the database.
thanks
k
 
He baked a muffin that stole my car! And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic