Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6868281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:24:53+00:00 2026-05-27T03:24:53+00:00

I am creating a server that creates a detached thread every time a client

  • 0

I am creating a server that creates a detached thread every time a client connects to the server.

    TRACE(DETAILED_TRACE,("Entered infinite loop of server.\n"));
    printf("\nThread counter = %d\n", thread_counter);
    printf("Waiting for connection...\n");

    len=sizeof(cliaddr);

    connfd=accept(sd,(struct sockaddr*)&cliaddr,&len);
    if (connfd < 0)
    {
        if (errno == EINTR)
            printf("Interrupted system call ??");
        else
            error_exit(SYSTEM_ERROR, "Connection");
    }
    if(FLAG_UNSET == server_stop_flag)
    {
        printf("Connection from %s\n",
               inet_ntop(AF_INET,&cliaddr.sin_addr,buf,sizeof(buf)));

        thread_return = pthread_create((th+thread_counter), NULL
                                       ,thread_func,(void*)&connfd);
        if(thread_return)
        {
            error_exit(SYSTEM_ERROR, "Thread Creation");
        }
        else
        {
            thread_return = pthread_detach(th[thread_counter
                                               ]);
            if(thread_return)
            {
                printf("\nError code: %d\n", thread_retu
                       rn);
                error_exit(SYSTEM_ERROR, "Detatch error"
                    );
            }
        }
        thread_counter++;
        thread_counter = thread_counter%MAX_THREADS;

while running valgrind i keep getting this:

===================================================================
16 bytes in 1 blocks are still reachable in loss record 1 of 2
   at 0x1B905301: calloc (vg_replace_malloc.c:176)
   by 0x9E7364: _dlerror_run (in /lib/libdl-2.3.4.so)
   by 0x9E6E3B: dlsym (in /lib/libdl-2.3.4.so)
   by 0x1B9106EE: open (vg_libpthread.c:2339)

LEAK SUMMARY:
   definitely lost: 0 bytes in 0 blocks.
   possibly lost:   0 bytes in 0 blocks.
   still reachable: 16 bytes in 1 blocks.
===============================================================

I keep getting the same leak summary no matter how many threads are created.
since the file the leak is in is a system file and not one of my own, i have implemented something in correctly. What could it be ?

I’ve run the same file in valgrind on another linux server now i’m getting this:

==12599== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 1)
==12599== malloc/free: in use at exit: 136 bytes in 1 blocks.
==12599== malloc/free: 6 allocs, 5 frees, 184 bytes allocated.
==12599== For counts of detected errors, rerun with: -v
==12599== searching for pointers to 1 not-freed blocks.
==12599== checked 10,580,680 bytes.
==12599==
==12599== 136 bytes in 1 blocks are possibly lost in loss record 1 of 1
==12599==    at 0x4905D27: calloc (vg_replace_malloc.c:279)
==12599==    by 0x358500D332: _dl_allocate_tls (in /lib64/ld-2.3.4.so)
==12599==    by 0x3585F066EE: pthread_create@@GLIBC_2.2.5 (in /lib64/tls/libpthr
ead-2.3.4.so)
==12599==    by 0x401222: main (test36.c:81)
==12599==
==12599== LEAK SUMMARY:
==12599==    definitely lost: 0 bytes in 0 blocks.
==12599==      possibly lost: 136 bytes in 1 blocks.
==12599==    still reachable: 0 bytes in 0 blocks.
==12599==         suppressed: 0 bytes in 0 blocks.

Is this a problem with the server ?
FYI: line no. 81 in test.c is the pthread_create call. is there something wrong with my create call ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:24:54+00:00Added an answer on May 27, 2026 at 3:24 am

    I don’t think you have anything to worry about. The leak summary says:

    LEAK SUMMARY:
    definitely lost: 0 bytes in 0 blocks.
    possibly lost: 0 bytes in 0 blocks.
    still reachable: 16 bytes in 1 blocks.
    

    and ‘still reachable’ memory has not been definitively lost, and it seems to be in system code as you identify, and it doesn’t increase with number of threads, all of which adds up to “nothing to worry about” in my book.

    Unless the amount of memory increases dramatically, or you can identify how it is your code that is possibly leaking memory, spend your time on other issues and not this one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Every new project that the client registers the system creates a folder to store
i'm creating a web app that's running on an Advantage Database server, not my
I am using creating a server/client style program, and it uses tcp connections. Now,
I'm creating a server/client solution with custom user logins (not WindowsIdentity). I need a
I have a web application that creates directories. The application works fine when creating
I need to develop an iPhone/iPod Touch application that creates a server to send
gcc 4.4.1 C99 I am creating a client server application. I have a Makefile
I have a java app that creates a socket to talk to a server
Database: SQL Server 2005 I'm using a function that creates a comma separated list
The situation : I am creating a server daemon in c that accepts numerous

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.