StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
memInfoTest.cc
1 #include "StMemoryInfo.hh"
2 
3 int main()
4 {
5  char *buf[4];
6  StMemoryInfo *info = StMemoryInfo::instance();
7 
8  info->snapshot();
9  info->print();
10 
11  buf[0] = new char[10000];
12  cout << "\n===> 10000 bytes allocated\n" << endl;
13  buf[0][9999] = 'a';
14 
15  info->snapshot();
16  info->print();
17 
18  buf[1] = new char[10000];
19  cout << "\n===> 10000 bytes allocated\n" << endl;
20  buf[1][9999] = 'a';
21 
22  info->snapshot();
23  info->print();
24 
25  buf[2] = new char[100000];
26  cout << "\n===> 100000 bytes allocated\n" << endl;
27  buf[2][99999] = 'a';
28 
29  info->snapshot();
30  info->print();
31 
32  buf[3] = new char[50000];
33  cout << "\n===> 50000 bytes allocated\n" << endl;
34  buf[3][49999] = 'a';
35 
36  info->snapshot();
37  info->print();
38 
39  delete [] buf[2];
40  cout << "\n===> 100000 bytes freed\n" << endl;
41 
42  info->snapshot();
43  info->print();
44 
45  buf[2] = new char[100000];
46  cout << "\n===> 100000 bytes allocated\n" << endl;
47  buf[2][99999] = 'a';
48 
49  info->snapshot();
50  info->print();
51 
52  for (int i=0; i<4; i++) delete buf[i];
53  cout << "\n===> all allocated memory freed\n" << endl;
54 
55  info->snapshot();
56  info->print();
57 
58  cout << "\ndone" << endl;
59  return 0;
60 }