Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 1481354 Details for
Bug 1626127
glibc: [RFE] Improve malloc performance in low-memory scenarios for threaded arenas.
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
malloc_nomem.c
malloc_nomem.c (text/plain), 1.87 KB, created by
Paulo Andrade
on 2018-09-06 15:55:28 UTC
(
hide
)
Description:
malloc_nomem.c
Filename:
MIME Type:
Creator:
Paulo Andrade
Created:
2018-09-06 15:55:28 UTC
Size:
1.87 KB
patch
obsolete
>#include <stdlib.h> >#include <string.h> >#include <unistd.h> >#include <pthread.h> >#include <stdio.h> >#include <assert.h> >#include <sys/time.h> >#include <sys/resource.h> > >/* gcc -O0 -std=c99 -m64 -o malloc_nomem malloc_nomem.c -lpthread */ > >void* alloc_one_block(void* unused) >{ > void* result = malloc(sizeof(void*)); > // Should be done with a condition variable but this is just a > // quick-and-dirty demo > sleep(1); > return result; >} > >void* alloc_until_failure(void* arg) >{ > int blocks = 0; > while(malloc(sizeof(void*))) > { > ++blocks; > } > printf("%s thread allocated %d blocks before failure\n", (char*) arg, blocks); > return NULL; >} > >int main(int argc, char* argv[]) >{ > int arena_count = argc > 1 ? atoi(argv[1]) : 2; > pthread_t* threads = calloc(sizeof(pthread_t), arena_count); > for(int count = 0; count < arena_count; ++count) > { > pthread_t thread; > int result = pthread_create(threads + count, NULL, alloc_one_block, NULL); > assert(result == 0); > } > for(int count = 0; count < arena_count; ++count) > { > void* allocated; > int result = pthread_join(threads[count], &allocated); > assert(result == 0); > printf("Thread %d allocated block at %p\n", count, allocated); > } > > struct rlimit limits; > limits.rlim_cur = 0; > limits.rlim_max = RLIM_INFINITY; > int result = setrlimit(RLIMIT_AS, &limits); > assert (result == 0); > printf("rlimit is now set\n"); > > alloc_until_failure("Main"); > > for(int count = 0; count < arena_count; ++count) > { > pthread_t thread; > int result = pthread_create(threads + count, NULL, alloc_until_failure, "Other"); > if(result != 0) > { > printf("pthread_create failed: %s\n", strerror(result)); > exit(1); > } > } > for(int count = 0; count < arena_count; ++count) > { > void* allocated; > int result = pthread_join(threads[count], &allocated); > assert(result == 0); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1626127
:
1481351
| 1481354