Click here to Skip to main content
15,740,971 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +

I am serializing following class object.This class is linked list.

------------- MyClass.h-----------

class MyClass : public CObject
MyClass *m_pNext;
int var1;
enum1 var2;
enum2 var3;
enum3 var4;
double[3] m_Normal;

// Serialization
void Serialize(CArchive& ar);

So here size of MyClass is very less and is less than 30-40 bytes.

------------- MyClass.cpp-----------


void MyClass::Serialize(CArchive& ar)

UINT objSch = ar.GetObjectSchema();

//store all variables

//Store Next pointer

ar<< m_pNext;
//Retrive all variables

//Deserialize Next pointer

ar >> m_pNext; // This is recursive deserialization call


Now here if MYClass linked list size is crossing ~4000 items limit.Stack overflow error occurs. This error comes only in vc10 and vc11. For same code and data size , stack overflow error does not come for vc9.

vc11 analysis data: Before De-Serialization starts: @esp = 2285040 I put breakpoint at the starts of seralization function. For each iteration MyClass stack grows by 512 bytes.The size of myclass is not that much. I think MFC internally using stack for his own purpose while deserialization.

So approximately after 4000 items: @esp = 2283968. At this point stack utlizaton is 2MB .So as stack totally exhausted ,crash occurs.

Our exe has stack limit of 2MB.

vc9 analysis data: Before De-Serialization : @esp = 2282960 Then for each Myclass stack grows by 336 bytes and it comes back to original or near to original value after one or two recursive calls. And at the end @esp = 2283968 after de-serializing 6000 items. So total stack used was 1000 bytes only. Seems like MFC serialization behavior is changed from vc9 to vc10/11 ,so stack is not getting reset to lower values in between recrsive calls.

Kindly let me know why this is happening ?

I aleardy have linked list data serialized for 6000 items. I want to deserialize these items.Can i retrive this recursivly stored data using any of non-recursive method (which will not require this recursive de-serialization call )?

Waiting for your reply.

Regards, Amit

PS- Recently i have modified this class to store COBJLIst retrived from linked list items.

And while deserialization we retrive this list and construct linked list out of it.

So now onwards save and retrive will not have any issu.Problem is ,i am trying to retrive old version data where in we have dumped linked list data.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900