Overview
| Artifact ID: | cf0b5ee52ab9cd6c692853cd7272a8c707f6e39d |
|---|---|
| Ticket: | 05d9a601e45db736729ed5b7a260dd675f245bb4 |
| Date: | 2016-04-04 17:23:03 |
| User: | rkeene |
| Artifact Attached: | f6158d2ba47c507f9bee8034b298933ebbff2a3e |
| Filename: | test-leak.c |
| Description: | Updated source |
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 58 59 60 61 62 63 64 65 66 67 68 69 70#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 pthreadCreateRet; int idx = 0; int tclMajor, tclMinor, tclPatchLevel; Tcl_FindExecutable(argv[0]); Tcl_GetVersion(&tclMajor, &tclMinor, &tclPatchLevel, NULL); printf("Testing Tcl version %i.%i.%i\n", tclMajor, tclMinor, tclPatchLevel); for (idx = 0;; idx++) { if ((idx % 1024) == 0) { idx = 0; printf("Thread Count: %llu, Interp Count: %llu\n", threadCount, interpCount); } pthreadCreateRet = pthread_create(&threadId, NULL, threadRunner, NULL); if (pthreadCreateRet != 0) { fprintf(stderr, "error: pthread_create() failed, exiting.\n"); return(1); } sleepTime.tv_sec = 0; sleepTime.tv_nsec = 1000000; nanosleep(&sleepTime, NULL); } return(0); }