Giter Club home page Giter Club logo

atomic_threadpool's Issues

There is probably a memory leak

I removed the condition in for-loop in threadpool_example.c to make an infinite loop and then the used memory is continuously rising. Is it the normal situation?

#include <stdio.h>
#if defined __GNUC__ || defined __CYGWIN__ || defined __MINGW32__ || defined __APPLE__
#include <pthread.h>
#elif defined _WIN32 || _WIN64
#include <windows.h>
#include <Windows.h>
#endif
#include "at_thpool.h"


#define TASK_SIZE 200

void t1(void *arg);
void t2(void *arg);
void t3(void *arg);
void t4(void *arg);

void t1(void *arg) {
        printf("t1 is running on thread \n");
}

void t2(void *arg) {
        printf("t2 is running on thread \n");
}

void t3(void *arg) {
        printf("t3 is running on thread \n");
}

void t4(void *arg) {
        printf("t4 is running on thread \n");
}

int main(void) {
        int nthreads = 8;//sysconf(_SC_NPROCESSORS_ONLN); // Linux

        printf("Share thread pool with %d threads with at lease totalthroughput * nthreads task size\n", nthreads);
        at_thpool_t *thpool = at_thpool_create(nthreads);

        printf("assigned %d tasks between %d threads\n", TASK_SIZE, nthreads);
        int i;
        for (i = 0; ; i++) { // here remove the condition
                at_thpool_newtask(thpool, t1, NULL);
                at_thpool_newtask(thpool, t2, NULL);
                at_thpool_newtask(thpool, t3, NULL);
                at_thpool_newtask(thpool, t4, NULL);
        }

#if defined _WIN32 || _WIN64
        Sleep(1000);
#else
        sleep(1);
#endif

        puts("shutdown thread pool");
        at_thpool_gracefully_shutdown(thpool);

        return 0;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.