Sponsored Content
Top Forums Shell Programming and Scripting Reserve resources (memory and processes) Post 302453784 by Corona688 on Thursday 16th of September 2010 11:38:14 AM
Old 09-16-2010
From the sounds of it you're on Linux, and running into the OOM-killer when things get tight. Correct me if I'm wrong.

Preallocating memory won't prevent the OOM-killer from hitting you, if anything, hogging more memory and more processes will put you higher in its list. Band-aiding a fix onto your scripts won't stop the server from running out of memory anyway, at best it'll deflect the OOM-kill to something else. What would they rather have die, your scripts, the memory-intensive processes, some daemon, or things more system-critical? They need to add more memory and/or swap, or to start restricting the stupid users that keep bombing the system.

One way to "preallocate" memory in a shell would be to make and clear a large shell variable, I suppose, but that's subject to the max size of a shell variable in your shell and all kinds of hackish and ugly and unlikely to work:
Code:
MEMHOG="$(dd if=/dev/zero count=1024 bs=1024 2> /dev/null | tr '\000' 'a')"
MEMHOG=""


Last edited by Corona688; 09-16-2010 at 12:44 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How to find memory and other resources in AIX

Hi, Im trying to find memory and other resources in IBM AIX. Please let me know how to do this. (3 Replies)
Discussion started by: R00tSc0rpi0n
3 Replies

2. Solaris

Reserve Memory for Global Zone

We have several containers on one machine and would like to reserve some memory for the global zone. capped-memory only allows max physical/swap and setting a max on each container isn't an option. The server has 32GB physical and 30GB swap. Currently there are ten containers on it. Normally... (6 Replies)
Discussion started by: kharjahn
6 Replies

3. Shell Programming and Scripting

Processes in Shared Memory

Hello , I would like to know how to check if a given process id belongs to particualr shared memory segment . Please help Thanks in advance (3 Replies)
Discussion started by: rmv
3 Replies

4. Homework & Coursework Questions

processes and shared memory

Hi again! I have 2 questions ..: How can i create exactly one number of processes ? For example i want to create l*n processes and i tried this: for(i=0;i<l*n;i++){ pid=fork()} But it creates more than l*n Also, i want each child to run another x.c program with 3 command line... (1 Reply)
Discussion started by: giampoul
1 Replies

5. Homework & Coursework Questions

processes and shared memory

Hi again! I have 2 questions ..: How can i create exactly one number of processes ? For example i want to create l*n processes and i tried this: for(i=0;i<l*n;i++){ pid=fork()} But it creates more than l*n Also, i want each child to run another x.c program with 3 command line... (1 Reply)
Discussion started by: giampoul
1 Replies

6. Solaris

How get memory and cpu usages of user's processes?

I have the processes (100+) by the oracle id and I'd to get the summarized view of the oracle processes' usage of the memory and the cpu. top would give me some, but not all. Thanks (3 Replies)
Discussion started by: iwmi
3 Replies

7. Red Hat

Best way to monitor use of memory resources for an RHEL instance

I wanted to know what is the best way to monitor use of memory on an RHEL server. We have 16 GB of memory for the RHEL instance but the usage at any time is more than 99%. I use /proc/meminfo on the server to check memory. I hope, my question is clear that what is the best way to monitor use of... (2 Replies)
Discussion started by: RHCE
2 Replies

8. Shell Programming and Scripting

List processes using my memory

Here is the output of top command So you see 99% of memory is in use -> Mem: 66005468k total, 65662548k used, How can I find out all processes consuming this 99% memory in descending order of consumption i.e. starting with processes eating more memory. I need the total of the output to... (3 Replies)
Discussion started by: mohtashims
3 Replies

9. Programming

JVM processes are not getting memory allocation as soon as started

Hi, i have this scenario, when i start about 20 java processes simultaneously in unix and run ps -eaf command i can see that processes are running but memory is not getting allocated to them immediately and it stays ideal for at least 10-15 min. Meanwhile i run free command to check the RAM,... (5 Replies)
Discussion started by: Vishal Gangrade
5 Replies

10. AIX

AIX memory usage by processes

Hi, i have 2 identical web servers using AIX. I use nmon analyser to check their performance. The server A exceeds 20% memory usage for system, 5% for cache and the rest 75% for processes. While, it uses 4% of Paging Space. The server B exceeds 20% for system, 45% for cache and 35% for processes.... (24 Replies)
Discussion started by: dim
24 Replies
exit(1) 							   User Commands							   exit(1)

NAME
exit, return, goto - shell built-in functions to enable the execution of the shell to advance beyond its sequence of steps SYNOPSIS
sh exit [n] return [n] csh exit [ ( expr )] goto label ksh *exit [n] *return [n] DESCRIPTION
sh exit will cause the calling shell or shell script to exit with the exit status specified by n. If n is omitted the exit status is that of the last command executed (an EOF will also cause the shell to exit.) return causes a function to exit with the return value specified by n. If n is omitted, the return status is that of the last command exe- cuted. csh exit will cause the calling shell or shell script to exit, either with the value of the status variable or with the value specified by the expression expr. The goto built-in uses a specified label as a search string amongst commands. The shell rewinds its input as much as possible and searches for a line of the form label: possibly preceded by space or tab characters. Execution continues after the indicated line. It is an error to jump to a label that occurs between a while or for built-in command and its corresponding end. ksh exit will cause the calling shell or shell script to exit with the exit status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the exit status is that of the last command executed. When exit occurs when executing a trap, the last command refers to the command that executed before the trap was invoked. An end-of-file will also cause the shell to exit except for a shell which has the ignoreeof option (See set below) turned on. return causes a shell function or '.' script to return to the invoking script with the return status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the return status is that of the last command executed. If return is invoked while not in a function or a '.' script, then it is the same as an exit. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
break(1), csh(1), ksh(1), sh(1), attributes(5) SunOS 5.10 15 Apr 1994 exit(1)
All times are GMT -4. The time now is 12:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy