I\'m running into problems serializing lots of objects in .NET. The object graph is pretty big with some of the new data sets being used, so I\'m getting:
Sy
Have you thought about the fact that Int32.MaxValue is 2,147,483,647 - over 2 billion.
You'd need 16GB of memory just to store the pointers (assuming a 64 bit machine), let alone the objects themselves. Half that on a 32bit machine, though squeezing 8GB of pointer data into the maximum of 3GB or so usable space would be a good trick.
I strongly suspect that your problem is not the number of objects, but that the serialization framework is going into some kind of infinite loop because you have referential loops in your data structure.
Consider this simple class:
public class Node
{
public string Name {get; set;}
public IList Children {get;}
public Node Parent {get; set;}
...
}
This simple class can't be serialised, because the presence of the Parent property means that serialisation will go into an infinite loop.
Since you're already implementing ISerializable, you are 75% of the way to solving this - you just need to ensure you remove any cycles from the object graph you are storing, to store an object tree instead.
One technique that is often used is to store the name (or id) of a referenced object instead of the actual reference, resolving the name back to the object on load.