Sponsored Content
Top Forums Programming Stress testing memory using malloc in linux ?? Post 302380168 by Corona688 on Monday 14th of December 2009 12:22:59 PM
Old 12-14-2009
Quote:
Originally Posted by frozensmilz
Hi to all,

Recently i am testing an equipment that runs in i586 fedora linux. I have to test mmap function. For that i determined to fill the memory and run the required application to check whether it throws any mmap error regarding low resources.

This is the line that does the allocation.
p = (long double *) malloc(BUFFSIZE);

In windows process explorer i have noticed that what ever value we give it to BUFFSIZE it will increase the size of "Private Bytes" but not working set memory or actual memory. In linux the memory still remains the same even after allocating about 1000MB.
Linux will show memory that is malloced but never used in any way under its' virtual memory stat.

If you want the system to actually run out of memory, and not kill random processes to regain it, you may want to turn overcommit and oom-kill off on your linux system. With overcommit enabled, it will only allocate memory you actually use. I cannot predict the effects of this on a system completely lacking in swap memory however -- why does your system not have it? Was Windows tested under these conditions too?

Code:
echo 2 > /proc/sys/vm/overcommit_memory
echo 0 > /proc/sys/vm/oom-kill

These settings are not persistent. If you reboot the machine, they will be set back to default values. Which are frankly more stable for reasons you're discovering -- it makes it harder for endless memory leaks to kill your machine. Not all versions of linux have /proc/sys/vm/oom-kill, I'm hunting for the alternative. You may find it listed by sysctl -A.
Quote:
The "memset" package is not available and cannot be installed
What memset package? If you mean the C function, it definitely has memset. You need to include <string.h>.

Last edited by Corona688; 12-14-2009 at 01:48 PM..
 

10 More Discussions You Might Find Interesting

1. Programming

malloc gives the same memory to two different nodes. How to deal with it?

When allocating memory for two different nodes, the resulting memory are the same. Clearly, this will lead to a mistake. This happened in a function. And the process must be in a function. (gdb) p tree->list $43 = (node *) 0x8be4180 (gdb) p tree->list $44 = (node *) 0x8be4180 At the... (2 Replies)
Discussion started by: cdbug
2 Replies

2. Solaris

how to stress the memory

Hi All, Is there way to stress memory on Solaris 10? If yes, how do I monitor the memory usage? (3 Replies)
Discussion started by: samnyc
3 Replies

3. UNIX and Linux Applications

Solaris & Linux memory stress test?

I'm looking for a script or some other application that will use up a lot of memory on a Solaris or Linux server, in order to test a monitoring application. So far I have found a script that's good for CPU usage but it does nothing for memory. I have also tried the application called 'stress'... (0 Replies)
Discussion started by: Kraas
0 Replies

4. Programming

Why memory allocated through malloc should be freed ?

Actually for a process to run it needs text, stack , heap and data segments. All these find a place in the physical memory. Out of these 4 only heap does exist after the termination of the process that created it. I want to know the exact reason why this happens. Also why the other process need to... (20 Replies)
Discussion started by: karthiktceit
20 Replies

5. Programming

Regarding the maximum memory allocated by malloc() function on HP-UX B11.11

In a 'C' program,when I am trying to allocate memory with the help of malloc () function, it is allocating the memory up to a certain limit for e.g. in my case, it is 670 MB (approx). malloc() returns NULL if I allocate more than this amount of memory.When I tried to allocate memory in chunks of... (1 Reply)
Discussion started by: vipinsachan
1 Replies

6. Shell Programming and Scripting

Stress testing php files at Unix/Linux Command line

Hi, Your great help is very appreciated. I am looking for any Unix command or tool for doing Stress/Load test of php files at command prompt. I tried torture.pl but it is not working after20 concurrent threads/users. as it is very urgent for me..please suggest ur ideas asap. thanks (5 Replies)
Discussion started by: Malleswari
5 Replies

7. Programming

./match_pattern.out: malloc(): memory corruption: 0x0000000013a11600 ***

Hi All, I have a simple code which does some computation by matching string patterns. In brief: 1. The code reads .dat and .txt files. 2. .dat files are huge text files and .txt files contain some important words. 3. I am just doing strstr to find the patterns. 4. The function returns the... (3 Replies)
Discussion started by: shoaibjameel123
3 Replies

8. Programming

glib detected: malloc() memory curruption

I am using libxml2 library for XMl parsing and libxml++ is C++ wrapper over that. So I am using API of libxml++. I am creating my class and composing instance xmlpp::Node *pNode in that. my class also have funciton prepareXPathQuery() which creates query string and have other fucntion... (2 Replies)
Discussion started by: sharadwagh
2 Replies

9. Programming

*** glibc detected *** ./a.out malloc() memory corruption

I am facing a problem of memory corruption. The loop runs for the first time but does not go through the second time. What could be the problem? for(int z=0;z<2;z++) { fp=fopen("poly.dat","r"); /*do something which reads this file into a 2D array*/ fclose(fp); ... (10 Replies)
Discussion started by: dare
10 Replies

10. UNIX for Beginners Questions & Answers

3rd party stress testing services

Hi all, bit of a forum newb here, so apologies if this has been covered else where, but I wonder if any of you has any experience with stress testing servers, specifically using 3rd party services. We run a very busy production system, and just haven't been able to simulate the user activity while... (1 Reply)
Discussion started by: dare99
1 Replies
shmx(8) 						      System Manager's Manual							   shmx(8)

Name
       shmx - shared memory exerciser

Syntax
       /usr/field/shmx [ -h ] [ -ofile ] [ -ti ] [ -mj ] [ -sk ] [ -v ]

Description
       The  memory exerciser spawns a background process and these two processes exercise the shared memory segments. They each take turns writing
       and reading the other's data in the segments.

       You can specify the number of memory segments to test and the size of the segment to be tested by and processes. The exerciser  runs  until
       the process receives a or a kill -15 pid.

       A  logfile  is  made in for you to examine and then remove. If there are errors in the logfile, check the file, where the driver and kernel
       error messages are saved.  The exerciser is automatically invoked when the exerciser is started.  You can also run by itself.

Options
       -h	 Print the help message for the command.

       -v	 Use the system call instead of to spawn

       -ofile	 Save diagnostic output in file.

       -ti	 Run time in minutes (i).  The default is to run until the process receives a or a kill -15 pid.

       -mj	 The memory segment size in bytes (j) to be tested by the processes.  Must be greater than 0.  The default is SMMAX/6.	(SMMAX	is
		 a system parameter set in the file

       -sk	 The number of memory segments (k).  The default is 6.	The maximum is also 6.

Examples
       The following example tests six memory segments (default), each with a segment size of SMMAX/6, until a or kill -15 pid is received:
       % /usr/field/shmx
       The following example runs three memory segments of size 100,000 bytes for 180 minutes in the background:
       % /usr/field/shmx -t180 -m100000 -s3 &

Restrictions
       If  there  is  a  need to run a system exerciser over an NFS link or on a diskless system there are some restrictions.  For exercisers that
       need to write into a file system, such as the target file system must be writable by root.  Also the directory, in which any of	the  exer-
       cisers  are  executed,  must be writable by root because temporary files are written into the current directory.  These latter restrictions
       are sometimes difficult to overcome because often NFS file systems are mounted in a way that prevents root from writing into them.  Some of
       the restrictions may be overcome by copying the exerciser to another directory and then executing it.

See Also
       Guide to System Exercisers

																	   shmx(8)
All times are GMT -4. The time now is 01:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy