我有2 GB的RAM.我们有一个执行导出/导入操作的应用程序.我们有一个递归函数,它有一个类型为Set的局部变量,它会在每次迭代时继续填充.这个集合不断增长,一度我们的内存耗尽.
是否有可以最佳地使用内存的替代数据结构?
这是粗略的代码
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);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2387 次 |
| 最近记录: |