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 6363043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:59:10+00:00 2026-05-24T23:59:10+00:00

In a networking project I have multiple objects that each have a message queue

  • 0

In a networking project I have multiple objects that each have a message queue (linked list). Each object also has a few clients, and each client has a pointer to a node in the queue. When a client receives the message its pointer points to, its pointer goes to the next message in the queue. Now, when all the clients have received a message, I want that message to be freed so it doesn’t take up memory. I did this by having a separate thread go through the objects and delete the unneeded messages, acting as a GC, but is there a better way of doing it?

Thanks.

  • 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-24T23:59:11+00:00Added an answer on May 24, 2026 at 11:59 pm

    You might be able to use reference counting to handle this. Assuming that all of the pointers to the queue elements are from the outside in (and never between queue elements), you can store in the queue cell a count of the number of pointers to it. Whenever you add a new pointer, you increment this reference count, and whenever a part of the program is done using the cell it drops the reference count, freeing it when it reaches zero. That way, as long as there’s an outstanding pointer to the cell, it won’t be freed, and as soon as the last reference to the queue cell is broken it will be reclaimed. You don’t need a separate thread to do this.

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

Sidebar

Related Questions

I am implementing some networking stuff in our project. It has been decided that
I've downloaded a few networking apps (games) that have you log in, then take
I have a networking Linux application which receives RTP streams from multiple destinations, does
I'm working on a social networking system that will have comments coming from several
I am doing an social networking project ,where i have an option to add/edit
I have heard that web-based chat clients tend to use networking frameworks such as
I have a C# application that uses the SerialPort object to establish a connection
I have a social networking website built upon the zend framework. My application also
Hey, I have a project where, after serialising an array of objects, I have
Are there any c++ networking libs that are very useful and robust? and libs

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.