HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- little program to stress test memory
Operating System - HP-UX
1825769
Members
2128
Online
109687
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2005 04:53 AM
05-11-2005 04:53 AM
I have this program that I got from this forum but I don't recall from who. I want to keep allocating chunks of memory to monitor memory alarms. It not doing what I thought it would do. Can someone who is familiar with C take a look at this? Here is the short code:
#include
#define CHUNK (1024 * 1024)
#define assign_errno(x) ((errno != 0) ? errno : (x))
extern int errno;
int main(argc,argv)
int argc;
char *argv[];
{
int cc = 0,stop = -1;
long tot = 0L;
char *p = NULL;
if (argc > 1) stop = atoi(argv[1]);
if (stop > 0)
{
int i = 0;
while (i < stop && cc == 0)
{
p = (char *) malloc((size_t) CHUNK);
if (p != NULL)
{
tot += CHUNK;
++i;
(void) printf("%4d. %9ld\n",i,tot);
}
else
{
cc = assign_errno(-1);
}
}
}
else
{
while (cc == 0)
{
p = (char *) malloc((size_t) CHUNK);
if (p != NULL)
{
tot += CHUNK;
(void) printf("%9ld\n",tot);
}
else cc = assign_errno(-1);
}
}
return(cc);
} /* main */
Any help would be appreciated.
Also, any other suggestions to allocate memory on a server to bring it to its knees would be great.
Thank you!!
Tony
Solved! Go to Solution.
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2005 06:40 AM
05-11-2005 06:40 AM
Solution
It look a little bit like a program I've posted in the past which was probably a sample program in an HP tech note. However, there are a *lot* of pieces of information missing, namely, how to compile the program for large amounts of RAM. The first is to change your kernel parameters maxdsiz and maxdsiz_64. You want maxdsiz to be as large as possible for a 32bit program but this is a moving target depending on the version of HP-UX you have and the patches you have added.
A straight compile will produce a program that simply grows to the size of maxdsiz (60 megs default or 250 megs for new versions of 11i). So in SAM, change maxdsiz to 2000megs and now the program will hit 900 megs. Make sure that maxdsiz_64 is LARGER than maxdsiz.
Now recompile the program with the flags -Ae -Wl -N as in:
cc -Ae -Wl -N -o mallocbig mallocbig.c
This changes the program to connect two 1Gb quadrants together and now the prgram will get about 1700 megs. But wait, there's more!!! Let's start with the opsystem: if it is only a 32bit OS (like 10.20 or 11.xx in 32bit), this is about as far as you can go. Use this to see what size the OS is running:
getconf KERNEL_BITS
If it says 64, keep going, it can get a *LOT* bigger. First, change maxdsiz (and maxdsia_64 if necessary) to 3Gb.
Now change the type of program to q3p (details are in the white papers and release notes):
chatr +q3p enable mallocbig
This changes the program to connect 3 quadrants together and you'll get about 2700megs. Change maxdsiz to Now change the program once again to use all 4 quadrants with:
chatr +q4p enable mallocbig
and you'll get about 3600 megs. But wait, let's bring out the big guns (the reason that 64bits is needed). Change maxdsiz_64 to 50Gb or maybe 200Gb. Then, recompile the program again like this:
cc -Ae -DD64 -o mallocbig mallocbig.c
and now the program will allocate as much memory as you have swap space, dozens to hundreds of Gb.
Now as I mentioned, success depends on patches, and you'll need the ANSI compiler to compile the program.
Now, VERY IMPORTANT: this program simply reserves the space and writes nothing into the space. Depending on how you measure memory usage, this large program may not be seen as most of it is bookeeping (virtual). I have attached a program that repeatedly asks you how many additional megs of RAM you would like, but it also writes a pattern into the RAM, thius forcing swapping and memory re-mapping. Use the exact same options as I mentioned above (they're also in the code).
Bill Hassell, sysadmin
A straight compile will produce a program that simply grows to the size of maxdsiz (60 megs default or 250 megs for new versions of 11i). So in SAM, change maxdsiz to 2000megs and now the program will hit 900 megs. Make sure that maxdsiz_64 is LARGER than maxdsiz.
Now recompile the program with the flags -Ae -Wl -N as in:
cc -Ae -Wl -N -o mallocbig mallocbig.c
This changes the program to connect two 1Gb quadrants together and now the prgram will get about 1700 megs. But wait, there's more!!! Let's start with the opsystem: if it is only a 32bit OS (like 10.20 or 11.xx in 32bit), this is about as far as you can go. Use this to see what size the OS is running:
getconf KERNEL_BITS
If it says 64, keep going, it can get a *LOT* bigger. First, change maxdsiz (and maxdsia_64 if necessary) to 3Gb.
Now change the type of program to q3p (details are in the white papers and release notes):
chatr +q3p enable mallocbig
This changes the program to connect 3 quadrants together and you'll get about 2700megs. Change maxdsiz to Now change the program once again to use all 4 quadrants with:
chatr +q4p enable mallocbig
and you'll get about 3600 megs. But wait, let's bring out the big guns (the reason that 64bits is needed). Change maxdsiz_64 to 50Gb or maybe 200Gb. Then, recompile the program again like this:
cc -Ae -DD64 -o mallocbig mallocbig.c
and now the program will allocate as much memory as you have swap space, dozens to hundreds of Gb.
Now as I mentioned, success depends on patches, and you'll need the ANSI compiler to compile the program.
Now, VERY IMPORTANT: this program simply reserves the space and writes nothing into the space. Depending on how you measure memory usage, this large program may not be seen as most of it is bookeeping (virtual). I have attached a program that repeatedly asks you how many additional megs of RAM you would like, but it also writes a pattern into the RAM, thius forcing swapping and memory re-mapping. Use the exact same options as I mentioned above (they're also in the code).
Bill Hassell, sysadmin
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP