LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-14-2006, 09:42 AM   #1
bayram
LQ Newbie
 
Registered: Dec 2006
Posts: 3

Rep: Reputation: 0
Question limits on memory resource


Hi!
I am a Mandrake user.
Suppose a (non-super)user wants to write a little program something like

char arr[2048576];
int main()
{
memset(arr, 65, 2048576);
return 0;
}

As you see he/she tries to allocate more than 1 MB memory.
My problem is to configure the Linux so that it will kill any process/program run by a non-superuser trying to use or allocate, say, more than 1 MB memory. How can I do it?
I have already tried to use ulimit, setrlimit and modify /etc/security/limits.conf, but it did not work.

Thank you in advance.
 
Old 12-14-2006, 09:59 AM   #2
cyber-worx
Member
 
Registered: May 2004
Location: England / Switzerland
Distribution: Gentoo, Ubuntu, Debian, Slackware
Posts: 138

Rep: Reputation: 15
Difficult to do, as the memory is assigned in pages by the kernel.

It is made even more difficult because of the way the kernel assess memory usage in linked applications (all that are not statically compiled)...

E.g
xterm itself needs say, 1mb
xterm links against a library that uses say, 5mb

if you start 2 xterms
Memory usage (in top etc) will show each xterm using 6mb, when in reality, the total usage is 7mb between both xterms, rather than the anticipated 12mb via top.
 
Old 12-14-2006, 10:12 AM   #3
bayram
LQ Newbie
 
Registered: Dec 2006
Posts: 3

Original Poster
Rep: Reputation: 0
Then, could we put a limit on number of pages?

Anyway, in fact my problem would be resolved if I could at least be able to detect the maximal size of memory used at a particular time of the execution of a process. I tried to use getrusage but it also failed, that is, it always shows 0 bytes. . Any idea?
 
Old 12-14-2006, 11:32 AM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
For limiting:
man bash
/ulimit

Specifically -l and -v.

To find usage: valgrind? ps? top?



Cheers,
Tink

Last edited by Tinkster; 12-14-2006 at 11:33 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
setting resource limits for jobs... pointfielder Red Hat 1 11-01-2006 06:34 AM
time and memory limits psmech Linux - General 2 02-15-2006 06:07 PM
array size/C++ memory limits for user space programs? thrifteed Programming 4 09-05-2004 04:42 AM
Resource exhaustion (memory) unSpawn Linux - Security 9 09-18-2002 10:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration