00001 #include "StMemoryInfo.hh"
00002
00003 int main()
00004 {
00005 char *buf[4];
00006 StMemoryInfo *info = StMemoryInfo::instance();
00007
00008 info->snapshot();
00009 info->print();
00010
00011 buf[0] = new char[10000];
00012 cout << "\n===> 10000 bytes allocated\n" << endl;
00013 buf[0][9999] = 'a';
00014
00015 info->snapshot();
00016 info->print();
00017
00018 buf[1] = new char[10000];
00019 cout << "\n===> 10000 bytes allocated\n" << endl;
00020 buf[1][9999] = 'a';
00021
00022 info->snapshot();
00023 info->print();
00024
00025 buf[2] = new char[100000];
00026 cout << "\n===> 100000 bytes allocated\n" << endl;
00027 buf[2][99999] = 'a';
00028
00029 info->snapshot();
00030 info->print();
00031
00032 buf[3] = new char[50000];
00033 cout << "\n===> 50000 bytes allocated\n" << endl;
00034 buf[3][49999] = 'a';
00035
00036 info->snapshot();
00037 info->print();
00038
00039 delete [] buf[2];
00040 cout << "\n===> 100000 bytes freed\n" << endl;
00041
00042 info->snapshot();
00043 info->print();
00044
00045 buf[2] = new char[100000];
00046 cout << "\n===> 100000 bytes allocated\n" << endl;
00047 buf[2][99999] = 'a';
00048
00049 info->snapshot();
00050 info->print();
00051
00052 for (int i=0; i<4; i++) delete buf[i];
00053 cout << "\n===> all allocated memory freed\n" << endl;
00054
00055 info->snapshot();
00056 info->print();
00057
00058 cout << "\ndone" << endl;
00059 return 0;
00060 }