- #!/bin/ksh
- #
- # glibc_malloc_tuneables1.ksh - Simple automated test for malloc tuneables
- #
- printf $"# Generating test source...\n"
- rm -f 'glibc_malloc_tuneables1.c'
- cat >'glibc_malloc_tuneables1.c' <<EOF
- #include <stdlib.h>
- #include <stdio.h>
- #include <unistd.h>
- int main(int ac, char *av[])
- {
- #define NUM_ARRAY_ELEMENTS (16)
- void *p[NUM_ARRAY_ELEMENTS];
- int i;
- /* Allocate */
- for (i=0 ; i < NUM_ARRAY_ELEMENTS ; i++)
- p[i] = malloc(16*1024*1024);
- (void)sleep(1);
- for (i=0 ; i < NUM_ARRAY_ELEMENTS ; i++)
- free(p[i]);
- return EXIT_SUCCESS;
- }
- EOF
- printf $"\n# Building test executable...\n"
- rm -f 'glibc_malloc_tuneables1'
- gcc -Wall -m32 -g glibc_malloc_tun#!/bin/ksh
- #
- # glibc_malloc_tuneables1.ksh - Simple automated test for malloc tuneables
- #
- printf $"# Generating test source...\n"
- rm -f 'glibc_malloc_tuneables1.c'
- cat >'glibc_malloc_tuneables1.c' <<EOF
- #include <stdlib.h>
- #include <stdio.h>
- #include <unistd.h>
- int main(int ac, char *av[])
- {
- #define NUM_ARRAY_ELEMENTS (16)
- void *p[NUM_ARRAY_ELEMENTS];
- int i;
- /* Allocate */
- for (i=0 ; i < NUM_ARRAY_ELEMENTS ; i++)
- p[i] = malloc(16*1024*1024);
- (void)sleep(1);
- for (i=0 ; i < NUM_ARRAY_ELEMENTS ; i++)
- free(p[i]);
- return EXIT_SUCCESS;
- }
- EOF
- printf $"\n# Building test executable...\n"
- rm -f 'glibc_malloc_tuneables1'
- gcc -Wall -m32 -g glibc_malloc_tuneables1.c -o glibc_malloc_tuneables1
- printf $"\n# Test run with default allocator settings\n"
- env - strace ./glibc_malloc_tuneables1 2>&1 | egrep 'mmap.*\(NULL,.+MAP_ANON.+\)'
- printf $"\n# Test run with MALLOC_MMAP_MAX_=0 allocator settings\n"
- env - MALLOC_MMAP_MAX_=0 strace ./glibc_malloc_tuneables1 2>&1 | egrep 'mmap.*\(NULL,.+MAP_ANON.+\)'
- # EOF.
- eables1.c -o glibc_malloc_tuneables1
- printf $"\n# Test run with default allocator settings\n"
- env - strace ./glibc_malloc_tuneables1 2>&1 | egrep 'mmap.*\(NULL,.+MAP_ANON.+\)'
- printf $"\n# Test run with MALLOC_MMAP_MAX_=0 allocator settings\n"
- env - MALLOC_MMAP_MAX_=0 strace ./glibc_malloc_tuneables1 2>&1 | egrep 'mmap.*\(NULL,.+MAP_ANON.+\)'
- # EOF.
glibc_malloc_tuneables1.ksh - Simple automated test for malloc tuneables
Posted by Anonymous on Mon 24th Jul 2023 11:19
raw | new post
view followups (newest first): glibc_malloc_tuneables1.ksh - Simple automated test for malloc tuneables by Anonymous
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.