1 | initial version |
long rss = 0L;
FILE* fp = NULL;
if ( (fp = fopen( "/proc/self/statm", "r" )) == NULL )
cout << "cant open \n"; /* Can't open? */
if ( fscanf( fp, "%*s%ld", &rss ) != 1 )
{
fclose( fp );
cout << "cant read \n"; /* Can't read? */
}
fclose( fp );
cout << (size_t)rss << "\n";
Found this way to measure the memory usage. This seems to work better than the ru_maxrss.
2 | No.2 Revision |
long rss = 0L;
FILE* fp = NULL;
if ( (fp = fopen( "/proc/self/statm", "r" )) == NULL )
cout << "cant open \n"; /* Can't open? */
if ( fscanf( fp, "%*s%ld", &rss ) != 1 )
{
fclose( fp );
cout << "cant read \n"; /* Can't read? */
}
fclose( fp );
cout << (size_t)rss << "\n";
Found this way to measure the memory usage. This seems to work better than the ru_maxrss.ru_maxrss.
At least it shows a more constant usage.
3 | No.3 Revision |
long rss = 0L;
FILE* fp = NULL;
if ( (fp = fopen( "/proc/self/statm", "r" )) == NULL )
cout << "cant open \n"; /* Can't open? */
if ( fscanf( fp, "%*s%ld", &rss ) != 1 )
{
fclose( fp );
cout << "cant read \n"; /* Can't read? */
}
fclose( fp );
cout << (size_t)rss << "\n";
Found this way to measure the memory usage. This seems to work better than the ru_maxrss.
At least it shows a more constant usage.usage and most likely this is also the current usage and not maxrss.