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

  • Home
  • SEARCH
  • 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 9003151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:40:35+00:00 2026-06-16T00:40:35+00:00

I took an example from https://www.kernel.org/doc/man-pages/online/pages/man3/pthread_create.3.html made it run infinitely(with small sleep so CPU

  • 0

I took an example from

https://www.kernel.org/doc/man-pages/online/pages/man3/pthread_create.3.html

made it run infinitely(with small sleep so CPU usage isnt a bottleneck so no queuing up of threads) by creating threads with pthread_create without ever calling pthread_join. That causes memory leaks and eventually PC runs out of memory. When I added pthread_detach immediately after creating the thread program behaves nicely and memory usage is constant after some time.

I was under impression that when a thread exits ( at closing } of the function that if given to pthread_create) all its resources are cleaned.

  • 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-06-16T00:40:36+00:00Added an answer on June 16, 2026 at 12:40 am

    I was under impression that when a thread exits ( at closing } of the function that if given to pthread_create) all its resources are cleaned.

    That’s a wrong impression. As you say, all resources are released for a finished thread when you either call pthread_join, or the thread is a detached thread.

    For a non-detached thread, some resources have to be kept around – otherwise you couldn’t get at the return value of the thread with a later call to pthread_join. A detached thread cannot be joined, so you can’t get an exit value from it.

    Many implementations store this return value on the stack of the thread, and thus keeps the entire stack around until someone calls pthread_join on a non-detached thread.

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

Sidebar

Related Questions

I took the example code from the Kendo UI demos at http://demos.kendoui.com/web/grid/remote-data.html , binding
So, I took some code from this Microsoft provided Example which allows me to
Last semester I took an online machine learning course from Standford taught by Professor
I am new to this html5. Today, i took an example from the below
I took an example of filling in a form in C# from another question,
I need to make a small openMP project. I took the example from the
I have downloaded example session bean servlet from here http://www.roseindia.net/jboss/sessionbeanservlet.shtml , download is under
I took two simple examples from Google Maps v.3 Documentation https://code.google.com/apis/maps/documentation/javascript/examples/maptype-base.html google-maps-utility-library-v3.googlecode.com/svn/tags/markermanager/1.0/examples/weather_map.html And I
I took this code straight from the w3 schools example, however, outside of their
I took the following code from the examples page on Asio class tcp_connection :

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.