aspose file tools*
The moose likes I/O and Streams and the fly likes de-serialization results in null values on large array, advice requested Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "de-serialization results in null values on large array, advice requested " Watch "de-serialization results in null values on large array, advice requested " New topic
Author

de-serialization results in null values on large array, advice requested

Daedalus Tien
Greenhorn

Joined: Dec 23, 2008
Posts: 4
Hi

I am trying to Serialize an array that contains about 150,000 objects. The problem is that each object in the array has a references to some other objects that are also in the array so I end up with a massive object tree where all the objects are referencing one another.

Unsuprisingly I get a stack overflow when I try to Serialize this array as serialization recursivly traverses the object graph. (i can not increase the stack size with this particular problem)

I tried iterating over each element of the array and calling writeObject on it but it made no difference I still got a stack overflow.

So I implemented the write and read object methods in the class of the objects that are held in the array but I dont think I have done it correctly because when I read in the file again into a new array the number of elements in the array and all the variables inside each of the objects exist but they are all Null or 0. So either it is not writing it properly or not reading it. I think it might be the latter as I dont think in.readObject does anything as far as I can tell.



I have also tried writing and reading each variable in the object but it comes up with stackOverFlowError when I try to write to the file.



Any body had these problems when doing Serialization on large numbers of selfreferencing objects? Can somebody point me in the right direction?
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2718
    
    6

"Daedalus andsomething" welcome to Javaranch
please check your private messages for an important administrative matter. You can see them by clicking the My Private Messages link above.


SCJP, SCWCD.
|Asking Good Questions|
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
In order to reproduce the problem, please post all of your code. While it's possible that the stack overflow is caused by the amount of data, could it also be that you have a reentrancy problem with your objects pointing at one another? That is, could you recreate the problem with a very small set of data? Also please post the full error.
Daedalus Tien
Greenhorn

Joined: Dec 23, 2008
Posts: 4
This post is over a year and a half old, best to let old threads die. I think I got round the problem by doing my own serialization instead of the built in Java serialization.
 
 
subject: de-serialization results in null values on large array, advice requested