Skip to content
Advertisement

What does the output of this program means?

I am trying to get the maximum virtual memory of the current process in Linux. And I am using getrlimit()

#include <stdio.h>
#include <sys/time.h>
#include <sys/resource.h>

struct rlimit rlim;
getrlimit(RLIMIT_AS,&rlim);
printf("Soft limit %ld",rlim.rlim_cur);
printf("Hard limit %ld",rlim.rlim_max);

I get -1 in both values. Shouldn’t I expect the virtual memory max allowed for the current process ?

Advertisement

Answer

The value RLIM_INFINITY denotes no limit on a resource (both in the structure returned by getrlimit() and in the structure passed to setrlimit()).

These are the default values for a process. Check the value of this constant.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement