views:

16

answers:

1

I have a web application that serialize a very complex object that has about 500 child objects to an SQL 2008 database. The problem is when the object is very large (more than 500 child objects) it generates an outofmemory exception and we need to restart the iis.

I am using the binary serializer in the .NET to serialize the object into a memory stream. I tried using a filestream also but it fails as well.

The total size of the object is when serialized to a file is about 15MB and the web server is a Windows 2008 IIS 7 32bit one.

I don't need to run any queries against this object. Just need to store it somewhere and then retrieve.

So please point me to the right direction here...

A: 

It is hard to answer this sort of question exactly without access to your system, there are too many unknowns. A 15MB file stream is not tiny, but it certainly isn't massive and your system should be able to handle it easily.

It could be that your web server just needs more RAM. Have you profiled the machine? It may not even be your serialization that is the main cause, maybe you have too much happening on that server to begin with.

You might also want to create your own custom serializer instead of using the ones built in to the framework. Or you might want to investigate the various opt in/opt out behaviours of the existing serializers and see whether you need to save everything in the object.

slugster