Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few memory leaks #48

Closed
megabyte1024 opened this issue Jan 13, 2012 · 6 comments
Closed

A few memory leaks #48

megabyte1024 opened this issue Jan 13, 2012 · 6 comments

Comments

@megabyte1024
Copy link

There are the following memory leaks:

  1. class client contains a shared pointer to a client session object (m_client_session), which is instanced in the client::init method. Also the client_session class contains a shared pointer to the parent session m_client. Instancing the client class object as its shared pointer reference counter equals to 1, after calling its init method the reference counter equals to 2, due to the reference in the session object. By deleting the client object reference becomes to 1 and the client object is never deleted.
    To resolve this cyclic dependency is necessary to use the boost::weak_ptr class instead of boost::shared_ptr for the client_session::m_client member.
  2. A similar cyclic dependency between the server and server_session classes. The server_session::m_server member type changing to boost::weak_ptr is required to fix it.
  3. If a server is stopped by calling of the stop method of the parent boost::asio::io_service instance and the server has connected clients, when active connections which are stored in connection_handler inherited class (the example chat_server_handler class) are not deleted. A fast but not universal solution to fix this issue is to mandatory clear the connections list (chat_server_handler::m_connections) after call of io_service.run.
@zaphoyd
Copy link
Owner

zaphoyd commented Jan 13, 2012

which branch does do these refer to?

@megabyte1024
Copy link
Author

The master branch. Just realized that exists the policy-refactor branch and is far as I understood, it is a trunk branch now. Correct?

@zaphoyd
Copy link
Owner

zaphoyd commented Jan 13, 2012

That is right. The policy refactor branch was unstable and feature incomplete for awhile so I worked on it separately from the old (but working) master branch. policy-refactor is largely done now and is just going through some final testing now before I merge it all back into master.

Regarding these errors in policy-refactor, the cyclic dependency between the endpoint/connection (previously server/session) was already resolved. I am working now on wrapping the io_service run, stop, reset calls to ensure that existing connections are cleaned up properly.

@megabyte1024
Copy link
Author

I see.. I think it possible to close the issue.

I downloaded the policy-refactor branch. Compiled the library under Windows. It was required to add new files and remove legacy ones. Surely the chat sample is not compilable, but the fuzzing_client is not compilable also. Is the fuzzing_client example possible to compile under Linux?

@zaphoyd
Copy link
Owner

zaphoyd commented Jan 13, 2012

I only have only started bringing the older examples up to spec with policy-refactor in the last week or so. The following should definitely be current:

  • echo_server
  • echo_client
  • echo_server_tls
  • broadcast_server
  • broadcast_client

fuzzing client/server and chat client/server may not be running yet on the latest build. I'll check, if not they should be trivial to fix.

@megabyte1024
Copy link
Author

Thank you a lot. I will try to compile the these examples under Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants