#include #include #include #include "JSystem/JShell.hh" #include "JSystem/JSystemToolkit.hh" #include "Jeep/JPrint.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to show memory usage. * \author mdejong */ int main(int argc, char **argv) { using namespace std; int size_B; int debug; try { JParser<> zap("Example program to show memory usage."); zap['M'] = make_field(size_B) = 1<<25; zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } using namespace JPP; //JShell shell; typedef long long int JType_t; const int size = size_B / sizeof(JType_t); cout << "Memory usage (start) "<< FIXED(5,2) << getMemoryUsage() << "%" << endl; JType_t* buffer = new JType_t[size]; cout << "Memory usage (new) "<< FIXED(5,2) << getMemoryUsage() << "%" << endl; for (int i = 0; i != size; ++i) { buffer[i] = i; } cout << "Memory usage (assign) "<< FIXED(5,2) << getMemoryUsage() << "%" << endl; delete[] buffer; cout << "Memory usage (delete) "<< FIXED(5,2) << getMemoryUsage() << "%" << endl; }