29 #include "StMemoryInfo.hh"
40 StMemoryInfo::StMemoryInfo()
42 #if !defined(__SUNPRO_CC) && !defined(__APPLE__)
43 mInfo = mOldInfo = mallinfo();
51 StMemoryInfo::operator=(
const StMemoryInfo &) {
return *
this;}
53 void StMemoryInfo::snapshot()
58 #if !defined(__SUNPRO_CC) && !defined(__APPLE__)
64 void StMemoryInfo::printLine(ostream& os,
const char* str,
int cur,
int old,
const char* unit)
68 os.setf(std::ios::left);
69 os << str <<
' ' << cur <<
" (";
70 os.setf(std::ios::showpos);
71 os << cur-old <<
") ";
74 os.unsetf(std::ios::showpos);
77 void StMemoryInfo::print(ostream& os)
79 os <<
"---------- Memory Status (snapshot #" << mCounter <<
") ----------" << endl;
80 #if defined(__SUNPRO_CC) || defined(__APPLE__)
81 os <<
"Sorry, StMemoryInfo is not supported on SUN." << endl;
82 #elif defined(__GNUC__)
83 printLine(os,
"total space allocated from system", mInfo.arena, mOldInfo.arena);
84 printLine(os,
"number of non-inuse chunks", mInfo.ordblks, mOldInfo.ordblks);
85 printLine(os,
"number of mmapped regions", mInfo.hblks, mOldInfo.hblks);
86 printLine(os,
"total space in mmapped regions", mInfo.hblkhd, mOldInfo.hblkhd);
87 printLine(os,
"total allocated space", mInfo.uordblks, mOldInfo.uordblks);
88 printLine(os,
"total non-inuse space", mInfo.fordblks, mOldInfo.fordblks);
89 printLine(os,
"top-most, releasable space", mInfo.keepcost, mOldInfo.keepcost);
91 printLine(os,
"total space in arena", mInfo.arena, mOldInfo.arena);
92 printLine(os,
"number of ordinary blocks", mInfo.ordblks, mOldInfo.ordblks);
93 printLine(os,
"number of small blocks", mInfo.smblks, mOldInfo.smblks);
94 printLine(os,
"space in holding block headers", mInfo.hblks, mOldInfo.hblks);
95 printLine(os,
"number of holding blocks", mInfo.hblkhd, mOldInfo.hblkhd);
96 printLine(os,
"space in small blocks in use", mInfo.usmblks, mOldInfo.usmblks);
97 printLine(os,
"space in free small blocks", mInfo.fsmblks, mOldInfo.fsmblks);
98 printLine(os,
"space in ordinary blocks in use", mInfo.uordblks, mOldInfo.uordblks);
99 printLine(os,
"space in free ordinary blocks", mInfo.fordblks, mOldInfo.fordblks);
100 printLine(os,
"space penalty if keep option is used", mInfo.keepcost, mOldInfo.keepcost);