COMPARISON BASIS | DISPOSE( ) | FINALIZE( ) |
---|---|---|
Defined | The method dispose( ) is defined in the interface IDisposable interface. | The method finalize( ) id defined in java.lang.object class. |
Syntax | public void Dispose( ){ // Dispose code here } | protected void finalize( ){ // finalization code here } |
Invoked | The method dispose( ) is invoked by the user. | The method finalize( ) is invoked by the garbage collector. |
Purpose | Method dispose( ) is used to free unmanaged resources whenever it is invoked. | Method finalize( ) is used to free unmanaged resources before the object is destroyed. |
Implementation | The method dispose( ) is to be implemented whenever there is a close( ) method. | The method finalize( ) is to be implemented for unmanaged resources. |
Access specifier | The method dispose( ) is declared as public. | The method finalize( ) is declared as private. |
Action | The method dispose( ) is faster and instantly disposes an object. | The method finalize is slower as compared to dispose |
Performance | The method disposes( ) performs the instantaneous action hence, does not effect the performance of websites. | The method finalize( ) being slower affects the performance of the websites. |
Difference between Dispose & Finalize Method
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment