• Post Reply Bookmark Topic Watch Topic
  • New Topic

Whats the difference between creating a new object v/s deserializing it froma file?

 
Alok Pota
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apart from speed, which is cheaper in terms of taking up less memory. Creating a new one or deserializing an object from the disk or reading an object using JDBC.
An object
#1 Map map1 = new HashMap();
or
ObjectInputStream rw =...
#2 map2 = (Map)rw.readObject();
#3
ResultSet rs = ..
map3 = (Map)rs.getObject("col1");
#1 is faster but does it take more memory compared to #2 & #3.

 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think they essentially take the same amount of memory for the Map, and #2 and #3 also take a lot of "temporary" memory during construction of the map.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!