以下是引用片段: class CJobDef { friend CArchive & Operator >> (CArchive &ar, CJobDef *def) { ar >> def->command; } friend CArchive & operator << (CArchive &ar, CjobDef *def) { ar << def->command; } private: std::string command; }; class CJobInst { friend CArchive & operator >> (CArchive &ar, CJobInst *inst) { inst->m_def = new CJobDef; ar >> inst->m_def; } friend CArchive & operator << (CArchive &ar, const CJobInst *inst) { ar << inst->m_def; } private: CJobDef *m_def; }; |
以下是引用片段: typedef Ref<CJobDef> CJobDefPtr; |
以下是引用片段: class CJobDef : public CReferable { friend CArchive &operator << (CArchive &ar, const CJobDefPtr &cand) { ar << cand->getTag(); CArchive ar_def(cand->getTag(), CArchive::WRITE); // write object attributes to ar_def return ar; } friend CArchive &operator >> (CArchive &ar, CJobDefPtr &cand) { int tag; ar >> tag; CArchive ar_def(tag, CArchive::READ); // read object attributes from ar_def cand.impersonate(tag); return ar; } }; class CJobInst : public CReferable { friend CArchive & operator << ( CArchive &ar, const CJobInstPtr &cand) { ar << cand->m_defPtr; return ar; } friend CArchive & operator >> (CArchive &ar, CJobInstPtr &cand) { CJobDefPtr defPtr = new CJobDef; ar >> defPtr; cand->m_defPtr = defPtr; return ar; } }; |
以下是引用片段: CJobDefPtr jobDefPtr = new CJobDef |
运行任务数 | 软件重启前的内存占用大小 | 软件重启后的内存占用大小 |
5000 | 25M | 32M |
100000 | 370M | 413M |
200000 | 730M | 795M |
新闻热点
疑难解答