Overview
| Artifact ID: | 011d1caea8e789863ef720a44ed0434abbd7bda3 |
|---|---|
| Ticket: | 05d9a601e45db736729ed5b7a260dd675f245bb4 |
| Date: | 2016-04-04 16:17:17 |
| User: | rkeene |
| Artifact Attached: | dd00b10c6255fc0e3e08009de674ebc9e9dcca43 |
| Filename: | test-leak.c |
| Description: | Test case |
Content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57#include <stdatomic.h> #include <pthread.h> #include <unistd.h> #include <stdio.h> #include <time.h> #include <tcl.h> _Atomic unsigned long long threadCount = 0; _Atomic unsigned long long interpCount = 0; void *threadRunner(void *arg) { Tcl_Interp *interp; int tclReturnValue; threadCount++; interp = Tcl_CreateInterp(); interpCount++; tclReturnValue = Tcl_Init(interp); if (tclReturnValue != TCL_OK) { fprintf(stderr, "warning: TclInit() failed.\n"); } Tcl_DeleteInterp(interp); interpCount--; Tcl_FinalizeThread(); threadCount--; return(NULL); } int main(int argc, char **argv) { pthread_t threadId; struct timespec sleepTime; int idx = 0; for (idx = 0;; idx++) { if ((idx % 1024) == 0) { idx = 0; printf("Thread Count: %llu, Interp Count: %llu\n", threadCount, interpCount); } pthread_create(&threadId, NULL, threadRunner, NULL); sleepTime.tv_sec = 0; sleepTime.tv_nsec = 1000000; nanosleep(&sleepTime, NULL); } return(0); }