openfoam/applications/test/maxMem/Test-maxMem.C
Mark Olesen f3670521cd STYLE: use std:: qualifier on ::abort, ::exit
- consistent with use of <cstdlib> and makes for a stronger distinct
  from Foam::abort etc.
2019-04-03 20:24:30 +02:00

34 lines
555 B
C

#include <iostream>
#include <cstdlib>
using namespace std;
int main(int argc, char *argv[])
{
if (argc != 2)
{
cerr << "Usage: " << argv[0] << " <number of Mb per chunk>\n";
exit(1);
}
int nBytes = (1024U*1024U)*atoi(argv[1]);
char *cPtr;
for (unsigned i=1;; i++)
{
cPtr = new char[nBytes];
/*
for (int j=0; j<nBytes; j++)
{
cPtr[j] = 0;
}
*/
cout << "allocated " << i*nBytes/(1024U*1024U) << " Mbytes" << endl;
}
return 0;
}