#include <sys/time.h> #include <sys/resource.h> #include <iostream.h> #include <unistd.h> #include <stdlib.h> int main() { struct rlimit rlim; int result = getrlimit(RLIMIT_AS, &rlim); int *a1 =(int *)malloc(20*sizeof(int)); if(a1 != NULL) cout<<"Memory allocated\n"; else cout<<"Memory allocation failed for the first time\n"; rlim.rlim_cur = 8; rlim.rlim_max = 8; result = setrlimit(RLIMIT_AS, &rlim); cout<<"\nRLIMIT_AS: "; cout<<"\n\tResult: "<<result; cout<<"\n\tSoft Limit: "<<rlim.rlim_cur; cout<<"\n\tHard Limit: "<<rlim.rlim_max<<endl; int *b1 =(int *)malloc(8*sizeof(int)); if(b1 != NULL) cout<<"Memory allocated\n"; else cout<<"Memory allocation failed for the first time\n"; free(a1); free(b1); return 0; } Expected Output: Memory allocated RLIMIT_AS: 0 8 8 Memory allocation failed for the first time Observed o/p: Memory allocated RLIMIT_AS: 0 8 8 Memory allocated Why this discrepancy??? Why the second time malloc didnt fail? Regards Shivali -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/