bash/perl script that will use up all memory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting bash/perl script that will use up all memory
# 1  
Old 12-22-2008
bash/perl script that will use up all memory

Hi,

Is there any known trick that will consume all of my memory and force my machine to swap? I'm scripting a monitor in perl that will alert me when available memory is dangerously low and system is swapping, and I would like to simulate the scenario. I am clueless how to make my system lack available memory.

Thanks,
Marc
# 2  
Old 12-22-2008
I don't know about any bash/perl ways to do that, but a small C program with malloc could to that.
See the attached file for a reference & feel free to use it as you wish.
# 3  
Old 12-22-2008
thanks, i'll use this when no other options are available. I was hoping to use something that I can hit ctrl+c on at the last minute... I'm not sure but I don't think memory will be released when i use malloc/relloc without free'ing, even after terminating the program.
# 4  
Old 12-22-2008
You're right of course, not free()'ing is bad, my mistake. I've added SIGINT-handling and free()'ing. If needed you can add a sleep() before the free in the main program.
# 5  
Old 12-22-2008
cool, thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to write a value to a physical memory address in bash script?

How would I write a value to a physical memory address? I was able to read a physical memory address (for example, 0x400) using this line: dd if=/dev/mem count=4 bs=1 skip=$(( 0x400 )) But I get an error: dd: 'standard input': cannot skip to specified offset when I try to write using... (1 Reply)
Discussion started by: rabrandt
1 Replies

2. Shell Programming and Scripting

Call a Perl script within a bash script and store the ouput in a .txt file

I'm attempting to write a bash script that will create a network between virtual machines. It accepts three arguments: an RSpec that describes the network topology, and two list of machines (servers and clients). I have a (working) Perl script that I want to call. This Perl script takes an RSpec... (6 Replies)
Discussion started by: mecaka
6 Replies

3. Programming

CGI Perl script to execute bash script- unable to create folder

Hi I have a bash script which takes parameters sh /tmp/gdg.sh -b BASE-NAME -n 1 -s /source/data -p /dest/data/archive -m ARC gdg.sh will scan the /source/data and will move the contents to /dest/data/archive after passing through some filters. Its working superb from bash I have... (0 Replies)
Discussion started by: rakeshkumar
0 Replies

4. Shell Programming and Scripting

Calling a Perl script in a Bash script -Odd Situation

I am creating a startup script for an application. This application's startup script is in bash. It will also need to call a perl script (which I will not be able to modify) for the application environment prior to calling the application. The problem is that this perl script creates a new shell... (5 Replies)
Discussion started by: leepet01
5 Replies

5. Shell Programming and Scripting

Hopefully a simple script, bash or perl...

I'm attempting to parse a file whose contents follow this format; 4:/eula.1028.txt: 8:/eula.1031.txt: 19:/eula.1033.txt: 23:/eula.1036.txt: 27:/eula.1040.txt: 31:/eula.1041.txt: 35:/eula.1042.txt: 39:/eula.2052.txt: 43:/eula.3082.txt: The number of lines of the file... (4 Replies)
Discussion started by: CudaPrime
4 Replies

6. Shell Programming and Scripting

Invoke a bash script with perl

Hi all, I use the perl script to invoke the bash script. and now there is a problem. my bash script lists as follows: and I use perl run this test scripts now the problem is when I run the perl script I find there is nothing recorded in the file /tmp/jdk.txt (2 Replies)
Discussion started by: Damon_Qu
2 Replies

7. Shell Programming and Scripting

Perl script run a bash script

Hi All, I think the processing of this is much more complex, so I will explain the whole process by codes. First,I wrote a expect script named bsim.exp as follows: #! /usr/local/bin/expect set command set name eval spawn $command switch -exact $command { "bash expecttest.sh" { ... (2 Replies)
Discussion started by: Damon sine
2 Replies

8. Shell Programming and Scripting

how to call a bash script using perl

Hi I m new to perl. I m trying to write a perl script that calls a bash script; does anyone have a script already that they can provide or help me out? Thanks a lot. (2 Replies)
Discussion started by: adnan786
2 Replies

9. Shell Programming and Scripting

Perl cgi script to call bash script?

Novice to perl here. I have created a simple web page in perl, with only one submit button. I would like to execute a bash script on the same server when this button is clicked on. Is this possible in perl? I have spent a few days researching this and am unable to find any useful information.... (0 Replies)
Discussion started by: pleonard
0 Replies

10. Shell Programming and Scripting

passing variable from bash to perl from bash script

Hi All, I need to pass a variable to perl script from bash script, where in perl i am using if condition. Here is the cmd what i am using in perl FROM_DATE="06/05/2008" TO_DATE="07/05/2008" "perl -ne ' print if ( $_ >="$FROM_DATE" && $_ <= "$TO_DATE" ) ' filename" filename has... (10 Replies)
Discussion started by: arsidh
10 Replies
Login or Register to Ask a Question