I have a RAM of 2 GB. We have a application which performs Export/Import operations. We have a recursive function which has one local variable of type Set which keeps on getting populated every iteration. This Set keeps growing and at one point we run out of memory.
Is there any alternative data structure which can optimally use the memory ?
Here's the rough code
GetObjectsForExportImpl(long lExportOptions, __int64 numIdProject, XExportSets
&exportSets, long lClientId, CComPtr<IEPIPDServer> ptrIPDServer,FILE *fp)
{
XExportSets exportLocal; //Thats a structure containing the Set
QueryObjectsForExport(lExportOptions, numIdProject, exportLocal,
lClientId, ptrIPDServer);
SetIDs::iterator it = exportLocal.setShared.begin();
for (; it != exportLocal.setShared.end(); ++it)
{
//recursive call
pExportObject->GetObjectsForExportImpl(lExportOptions,
numIdProject, exportSets, lClientId, ptrIPDServer,fp);
}
}
An alternative structure wouldn't help much. Say you switched to a class that uses half the memory. Still you're only delaying the doom.
A structure size of 2GB usually indicates you need to switch to a disk based structure, a database or a memory mapped hashtable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With