Re: [zones-discuss] Testing memory and swap caps
I found a tool on Freshmeat or SourceForge called "stress". It is a small stress test tool that can allocate memory in strides from multiple worker processes. Commonly I use the perl trick below which I learned from Brendan Gregg. Its kind of hackish, but it works. SunVTS is too big and refuses to work in non-global zones. What I've wanted but not had the time to write myself, is a general purpose memory tool to be able to allocated various types of memory (malloc, mmap, shm, etc) and generally pretend to be a real application, allocating and de-allocating and leaking memory. So far I have not found such a tool, but it would be helpful in fully understanding and testing Solaris RCTL. benr. Maidak Alexander J wrote: > I've used this before: > > perl -e '$a = "A" x 100_000_000; sleep 3600' & > > I think each perl onliner will chew up ~200MB memory. Add or remove a zero > for more or less consumption. > > -Alex > > -Original Message- > From: zones-discuss-boun...@opensolaris.org > [mailto:zones-discuss-boun...@opensolaris.org] On Behalf Of Paul Davis > Sent: Wednesday, March 11, 2009 9:44 AM > To: zones-discuss@opensolaris.org > Subject: [zones-discuss] Testing memory and swap caps > > > Is there a tool available that can incrementally consume memory in a zone? > > Thanks, > Paul > > > > ___ > zones-discuss mailing list > zones-discuss@opensolaris.org > ___ > zones-discuss mailing list > zones-discuss@opensolaris.org > ___ zones-discuss mailing list zones-discuss@opensolaris.org
Re: [zones-discuss] Testing memory and swap caps
Hi I use this one for teaching purposes. Can be used like this: gcc -o mem mem.c mem [ -p ][ -n <#pages> ][ -t ] You can easily watch memory consumption with pmap as anon grows... You can also see how Solaris works with multiple pasgesize support MPSS. Konstantin #include #include #include int getopt(int argc, char * const argv[], const char *optstring); int atoi(const char *str); void *malloc(size_t size); int main(int argc, char **argv) { extern int optind; extern char *optarg; int pagesize = PAGESIZE; int option; int err; int count = 1; int seconds = 10; char *buf; int loop; while ((option = getopt(argc, argv, "p:t:n:")) != EOF) { switch (option) { case 'p': pagesize = atoi(optarg); break; case 'n': count = atoi(optarg); break; case 't': seconds = atoi(optarg); break;; default: err++; } /* switch */ } /* while */ argc -= optind; argv += optind; while (1) { for (loop = 0; loop < count; loop++) { buf = malloc(pagesize); *buf = ' '; } printf("Consume about %d/%d kB/s.\n", count * pagesize, seconds); sleep(seconds); } } Maidak Alexander J schrieb: I've used this before: perl -e '$a = "A" x 100_000_000; sleep 3600' & I think each perl onliner will chew up ~200MB memory. Add or remove a zero for more or less consumption. -Alex -Original Message- From: zones-discuss-boun...@opensolaris.org [mailto:zones-discuss-boun...@opensolaris.org] On Behalf Of Paul Davis Sent: Wednesday, March 11, 2009 9:44 AM To: zones-discuss@opensolaris.org Subject: [zones-discuss] Testing memory and swap caps Is there a tool available that can incrementally consume memory in a zone? Thanks, Paul ___ zones-discuss mailing list zones-discuss@opensolaris.org ___ zones-discuss mailing list zones-discuss@opensolaris.org __ Hinweis von ESET NOD32 Antivirus, Signaturdatenbank-Version 3927 (20090311) __ E-Mail wurde geprüft mit ESET NOD32 Antivirus. http://www.eset.com ___ zones-discuss mailing list zones-discuss@opensolaris.org
Re: [zones-discuss] Testing memory and swap caps
I've used this before: perl -e '$a = "A" x 100_000_000; sleep 3600' & I think each perl onliner will chew up ~200MB memory. Add or remove a zero for more or less consumption. -Alex -Original Message- From: zones-discuss-boun...@opensolaris.org [mailto:zones-discuss-boun...@opensolaris.org] On Behalf Of Paul Davis Sent: Wednesday, March 11, 2009 9:44 AM To: zones-discuss@opensolaris.org Subject: [zones-discuss] Testing memory and swap caps Is there a tool available that can incrementally consume memory in a zone? Thanks, Paul ___ zones-discuss mailing list zones-discuss@opensolaris.org ___ zones-discuss mailing list zones-discuss@opensolaris.org
Re: [zones-discuss] Testing memory and swap caps
Not sure. It's been like half a lifetime since I have written any C code, but somewhere in some dust-covered brain cells I have a recollection that a malloc doesn't actually consume the memory until the memory is actually populated, probably as being a linked-list type data structure. I really am not sure if this is correct or just severely historic knowledge. Paul Alexander Skwar wrote: Hi! On Wed, Mar 11, 2009 at 15:44, Paul Daviswrote: Is there a tool available that can incrementally consume memory in a zone? How about just doing malloc() calls until you hit your limit? Or is that a flawed approach? I wrote a small program which does just that; you can find it at http://askwar.pastebin.ca/1336018 and also attached to this mail, as it's so small. Alexander -- [ Soc. => http://twitter.com/alexs77 | http://www.plurk.com/alexs77 ] [ Mehr => http://zyb.com/alexws77 ] [ Chat => Jabber: alexw...@jabber80.com | Google Talk: a.sk...@gmail.com ] [ Mehr => MSN: alexw...@live.de | Yahoo!: askwar | ICQ: 350677419 ] Sent from: Schaffhausen Schaffhausen Schweiz. ___ zones-discuss mailing list zones-discuss@opensolaris.org
Re: [zones-discuss] Testing memory and swap caps
Hi! On Wed, Mar 11, 2009 at 15:44, Paul Davis wrote: > Is there a tool available that can incrementally consume memory in a zone? How about just doing malloc() calls until you hit your limit? Or is that a flawed approach? I wrote a small program which does just that; you can find it at http://askwar.pastebin.ca/1336018 and also attached to this mail, as it's so small. Alexander -- [ Soc. => http://twitter.com/alexs77 | http://www.plurk.com/alexs77 ] [ Mehr => http://zyb.com/alexws77 ] [ Chat => Jabber: alexw...@jabber80.com | Google Talk: a.sk...@gmail.com ] [ Mehr => MSN: alexw...@live.de | Yahoo!: askwar | ICQ: 350677419 ] Sent from: Schaffhausen Schaffhausen Schweiz. #include /* malloc*/ #include int main(void) { /* Allocate space for an array with ten elements of type int. */ int *ptr1 = malloc(1 * 1024 * 1024 * 1024); if (ptr1 == NULL) { printf("1 Memory could not be allocated, the program should handle the error here as appropriate.\n"); } else { printf("1 Allocation succeeded. Do something.\n"); int *ptr2 = malloc(1 * 1024 * 1024 * 1024); if (ptr2 == NULL) { printf("2 Memory could not be allocated, the program should handle the error here as appropriate.\n"); } else { printf("2 Allocation succeeded. Do something.\n"); int *ptr3 = malloc(1 * 1024 * 1024 * 1024); if (ptr3 == NULL) { printf("3 Memory could not be allocated, the program should handle the error here as appropriate.\n"); } else { printf("3 Allocation succeeded. Do something.\n"); int *ptr4 = malloc(1 * 1024 * 1024 * 1024); if (ptr4 == NULL) { printf("4 Memory could not be allocated, the program should handle the error here as appropriate.\n"); } else { printf("4 Allocation succeeded. Do something.\n"); int *ptr5 = malloc(1 * 1024 * 1024 * 1024); if (ptr5 == NULL) { printf("5 Memory could not be allocated, the program should handle the error here as appropriate.\n"); } else { printf("5 Allocation succeeded. Do something.\n"); int *ptr6 = malloc(1 * 1024 * 1024 * 1024); if (ptr6 == NULL) { printf("6 Memory could not be allocated, the program should handle the error here as appropriate.\n"); } else { printf("6 Allocation succeeded. Do something.\n"); int *ptr7 = malloc(1 * 1024 * 1024 * 1024); if (ptr7 == NULL) { printf("7 Memory could not be allocated, the program should handle the error here as appropriate.\n"); } else { printf("7 Allocation succeeded. Do something.\n"); int *ptr8 = malloc(1 * 1024 * 1024 * 1024); if (ptr8 == NULL) { printf("8 Memory could not be allocated, the program should handle the error here as appropriate.\n"); } else { printf("8 Allocation succeeded. Do something.\n"); int *ptr9 = malloc(1 * 1024 * 1024 * 1024); if (ptr9 == NULL) { printf("9 Memory could not be allocated, the program should handle the error here as appropriate.\n"); } else { printf("9 Allocation succeeded. Do something.\n"); int *ptr10 = malloc(1 * 1024 * 1024 * 1024); if (ptr10 == NULL) { printf("10 Memory could not be allocated, the program should handle the error here as appropriate.\n"); } else { printf("10 Allocation succeeded. Do something.\n"); int *ptr11 = malloc(1 * 1024 * 1024 * 1024); if (ptr11 == NULL) { printf("11 Memory could not be allocated, the program should handle the error here as appropriate.\n"); } else { printf("11 Allocation succeeded. Do something.\n"); int *ptr12 = malloc(1 * 1024 * 1024 * 1024); if (ptr12 == NULL) { printf("12 Memory could not be allocated, the program should handle the error here as appropriate.\n"); } else { printf("12 Allocation succeeded. Do something.\n"); int *ptr13 = malloc(1 * 1024 * 1024 * 1024); if (ptr13 == NULL) { printf("13 Memory could not be allocated, the program should handle the error here as appropriate.\n"); } else { printf("13 Allocation succeeded. Do something.\n"); int *ptr14 = malloc(1 * 1024 * 1024 * 1024); if (ptr14 == NULL) { printf("14 Memory could not be allocated, the program should handle the error here as appropriate.\n"); } else { printf("14 Allocation succeeded. Do something.\n"); int *ptr15 = malloc(1 * 1024 * 1024 * 1024); if (ptr15 == NULL) { printf("15 Memory could not be allocated, the program should handle the error here as appropriate.\n"); } else { printf("15 Allocation succeeded. Do something.\n"); int *ptr16 = malloc(1 * 1024 * 1024 * 1024); if (ptr16 == NULL) {