Results 1 to 4 of 4
Hi
Is there any mechanism in Linux where in I can specify the maximum heap which my program can use?...
- 05-16-2007 #1Just Joined!
- Join Date
- May 2007
- Posts
- 5
Restricting the heap usage of my program
Hi
Is there any mechanism in Linux where in I can specify the maximum heap which my program can use?
- 05-16-2007 #2Linux Enthusiast
- Join Date
- Jan 2005
- Posts
- 575
The closest thing I know to what you want is setrlimit()
- 05-16-2007 #3Just Joined!
- Join Date
- May 2007
- Posts
- 5
thanks for replying...
i am trying to use this API but not getting how it will through the error.
below is my code:
The code gives segmentation fault error once the execution of main is completed.Code:int main(int argc, char *argv[]) { GdkPixbuf *pixbuf = NULL; GError *error = g_new(GError, 1); struct rlimit *value; getrlimit(RLIMIT_DATA, value); value->rlim_max = 1000000; setrlimit(RLIMIT_DATA, value); g_type_init(); pixbuf = gdk_pixbuf_new_from_file("images.jpg", error); return 0; }
Let me know is this is the correct way of using setrlimit();
thanks
- 05-16-2007 #4Just Joined!
- Join Date
- May 2007
- Posts
- 5
the updated code is
Now segmentation fault is not coming.Code:int main(int argc, char *argv[]) { GdkPixbuf *pixbuf = NULL; GError *error = g_new(GError, 1); struct rlimit value; value->rlim_cur = 0; value->rlim_max = 0; setrlimit(RLIMIT_DATA, &value); g_type_init(); pixbuf = gdk_pixbuf_new_from_file("images.jpg", error); printf("errno = %d", errno); return 0; }
But the thing is the code should print the value of errno as ENOMEM(12) but its printing 0.
Please let me know the reason fo this ??


Reply With Quote