Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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.
 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic