Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 300
  • Last Modified:

Object Deallocation

HSSFWorkbook hsswb = new HSSFWorkbook();
    HSSFSheet sheet = hsswb.createSheet("Abstract collection report");


If i declare this type of object in JSP and do not deallocate them
what will be the effect..

Is it necessary to do it..
0
Ritug
Asked:
Ritug
  • 5
1 Solution
 
sompol_kiatkamolchaiCommented:
You do not need to do that. Garbage collector will help you maintain unused instance of object.
It will cleanup automatically if there is no reference to that object.
0
 
sompol_kiatkamolchaiCommented:
In more detail about garbage collection.

Garbage collection is an mechanism that java virtual machine use for maintaining memory. The object that is not used anymore which JVM detect by check whether there is any reference to it or not. If not the container will decide to garbage that object from memory. We will not know when container(JVM) will decide to do that. Container start to do it by themselve.

Here is an example

String a="abc";  // this will create instance of string "abc" in memory and point or reference by variable a
a=null; // set a reference to null so "abc" instance can not refer to anymore
//container will clean "abc" later....


Regards,

0
 
RitugAuthor Commented:
Thanks for assistance
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
sompol_kiatkamolchaiCommented:
Best of luck. :)
0
 
umangjoshiCommented:
set it to null, rest will be handle by garbage collector.
0
 
sompol_kiatkamolchaiCommented:
Please accept my answer if you feel your problem is over. :)
0
 
sompol_kiatkamolchaiCommented:
Thanks mate.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now