• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GC behavior on Serializable objects

 
Ananth Chellathurai
Ranch Hand
Posts: 349
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • 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
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • 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
 
Gamini Sirisena
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • 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
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • 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
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • 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
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • 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
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • 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
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • 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
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic