• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

GC behavior on Serializable objects

 
Ranch Hand
Posts: 349
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,

I am trying to fix the performance problems in my application.

1. How does a serializable object serialized. When I profiled the application, I never see this object GCd.



I use sweetdev ria tree in my application.

On every refresh of my JSP page, increases new objects which are related to the tree. My TreeDataProvider implements ITreeDataProvider which extends Serializable.

The objects are removed from memory only when I restart my tomcat. I have controlled the increase of memory due to nodeTypes, by making the node types as constants. But I could not make the TreeDataProvider a constant as it varies and not a constant.

I am not sure on what do I miss here. Does gc behaves differently if my class extends Serializable?

Any helps would be appreciated.

Regards
Ananth Chellathurai
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Does gc behaves differently if my class extends Serializable?



No. If the object is not GCed, there is probably a reference to it hanging around somewhere.

Bill
 
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you implement Serializable?

Do you serialize it to disk or do you remote the object?
 
Ananth Chellathurai
Ranch Hand
Posts: 349
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I am using sweetdev ria library, the dataprovider class implements ITreeDataProvider which extends Serializable.
I do not want my objects to be stored to the disk. Not sure on whether the license terms allows me to edit the code.

Ananth Chellathurai
[ September 26, 2008: Message edited by: Ananth Chellathurai ]
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What provision does the "ITreeDataProvider" class have for cleaning up after you are finished with an instance?

Bill
 
Ananth Chellathurai
Ranch Hand
Posts: 349
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you get OutOfMemoryErrors? If not, it might just be that the gc decided that it isn't yet time to gc the instances.
 
Ananth Chellathurai
Ranch Hand
Posts: 349
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do not get outofmemory errors, however when I refresh the jsp page, I see the memory keeps growing for every refresh.

Ananth Chellathurai
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ananth Chellathurai:
I do not get outofmemory errors, however when I refresh the jsp page, I see the memory keeps growing for every refresh.



That's normal behavior. Just because an object *could* be gc'ed, it doesn't mean that it necessarily *will*.
 
Ananth Chellathurai
Ranch Hand
Posts: 349
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I force an object to be gced, other than using System.gc, I would like a specify an object to get gced.

Is there any other suggestions to fix my memory problems?

Ananth Chellathurai
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lets get back to the original question:

I am trying to fix the performance problems in my application.



Exactly what is the performance problem?

If you are not running out of memory, why are you worrying at all? Let Java take care of the memory GC and get on with programming the application.

Bill
 
My, my, aren't you a big fella. Here, have a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic