Recommended: Sing it, brah! 5 fabulous songs for developers
JW's Top 5
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 7 of 7
>java -Xmx8m Main clone implementation: Object.clone() count = 5978 Exception in thread "main" java.lang.OutOfMemoryError ... clone implementation: copy construction count = 5978 ... clone implementation: serialization count = 747 ... clone implementation: reflection count = 5952
Approach 3's overhead increases with the number of immutable fields in a class. Removing this overhead is nontrivial.
The following table recaps the properties of all cloning approaches in this article from several perspectives: speed, resource utilization, class design constraints, object graph handling.
|
||||||||||||||||||||||||||||||||||||||||
This article discussed implementing a single method, Object.clone(). It is amazing that a single method can have so many implementation choices and subtle points. I hope this article provided
you with some food for thought and useful guidelines for your application class design.