jQuery in Action, 3rd edition
The moose likes Performance and the fly likes Serialization Vs Externalisation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "Serialization Vs Externalisation" Watch "Serialization Vs Externalisation" New topic

Serialization Vs Externalisation

Anil Vupputuri
Ranch Hand

Joined: Oct 31, 2000
Posts: 527

How does the performance effect on Externalisation over Serialization.

SCJP 1.5, SCEA, ICED (287,484,486)
Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
Externalization allows you to customize how serialization is done. By implementing externalization you are controlling what gets serialized ( and what doesnot ) as versus default serialization where all non-transient attributes get serialized.
For "fat data" classes with a large number of attributes only a few of which needs to persisted, externalization will help you reduce the size of serialized stream and the time taken to serialize the object. But there will be an overhead involved because the runtime has to call your methods to read/write objects.
This is all I can think of, nothing else comes to my mind in terms of performance benefits. Anyone??

Ajith Kallambella M.
Sun Certified Programmer for the Java2 Platform.

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Kartik Shah
Ranch Hand

Joined: Dec 07, 2000
Posts: 102
1. Further more if you are subclassing your externalizable class you will want to invoke your superclass's implementation. So this causes overhead while you subclass your externalizable class.
2. methods in externalizable interface are public. So any malicious program can invoke which results into lossing the prior serialized state.

Kartik Shah
SCJP, SCDJWS, IBM Certified Websphere & XML, PMP & Six Sigma - http://blog.kartikshah.info
Jack Shirazi
Ranch Hand

Joined: Oct 26, 2000
Posts: 96
Ajith wrote:
"But there will be an overhead involved because the runtime has to call your methods to read/write objects."
Serialization has huge overheads in having to paw through private stuff via the JVM that is normally unavailable, and also with all the reflection it uses. Externalization is a simple method call.
There is no overhead to the calls to your methods, it normally works out faster. Perverse, but true.
--Jack http://www.JavaPerformanceTuning.com/
I agree. Here's the link: http://aspose.com/file-tools
subject: Serialization Vs Externalisation
It's not a secret anymore!