Hey Mili, thanks for the tips. We Java programmers get lazy at times thanks
to the garbage collector and forget that there actually some things we need
to take care of ourselves (like closing files and database connections and
statements).

Your second tip doesn't seem to make sense though:

> 2) If passing an object to a method, make sure you assign the 
> object=null
> once you are through with the method. It wont affect the 
> original object as
> in Java objects are not passed by reference...

The parameters passed to a method are stored on the stack. They are removed
when the method exits (since the stack frame for the method is then cleaned
up). So setting the reference to null right before exiting the method really
has no effect. And just to clarify: Java objects _are_ passed by reference.
However, the arguments to a method are passed by value. For objects, the
argument is an object _reference_, so the reference is passed by value and
changing it in the method will not change the reference in the calling
method.

If POI really writes 65000 rows to file, that might be worth fixing in
CVS... Any POI developers on this list that can comment?


Regards,
Frans



> -----Original Message-----
> From: Mili Aggarwal, Noida [mailto:[EMAIL PROTECTED]
> Sent: Friday, April 08, 2005 6:29 AM
> To: POI Users List
> Subject: RE: out of memory.
> 
> 
> Hey Vyom,Thanks for the help I sorted it out...Actually the memory was
> leaking due t non-closure of  a prepared Statement but there 
> are some GREAT
> Java lessons that I learnt which I thought I must share with you guys:
> 
>  
> 
> 1) Whenever coding that requires DB connectivity do remember 
> do double check
> that all your DBConnections,PreparedStatements,ResultSet are properly
> closed.
> 
> 2) If passing an object to a method, make sure you assign the 
> object=null
> once you are through with the method. It wont affect the 
> original object as
> in Java objects are not passed by reference...
> 
>  
> 
> I know it's a POI forum but I thought why not share some Java 
> intricacies.
> 
>  
> 
> 3) I came across a tool that detects memory leak and tells 
> what all objects
> are present in memory. It can really help someone to optimize 
> the code. It
> comes with BEA's Jrockit. Try it out. Its awesome.
> 
>  
> 
> http://e-docs.bea.com/wljrockit/docs142/userguide/memleak.html
> <http://e-docs.bea.com/wljrockit/docs142/userguide/memleak.html> 
> 
>  
> 
> (I am not working for BEA ;-) )
> 
>  
> 
> 4) Another article of interest that I came up with is:
> 
<<cut>>


-----------------------------------------------------------------
ATTENTION:
The information in this electronic mail message is private and
confidential, and only intended for the addressee. Should you
receive this message by mistake, you are hereby notified that
any disclosure, reproduction, distribution or use of this
message is strictly prohibited. Please inform the sender by
reply transmission and delete the message without copying or
opening it.

Messages and attachments are scanned for all viruses known.
If this message contains password-protected attachments, the
files have NOT been scanned for viruses by the ING mail domain.
Always scan attachments before opening them.
-----------------------------------------------------------------

Reply via email to