C++ API cannot release resource

Post here your questions about the C++ API for SFS2X

Moderators: Lapo, Bax, MBagnati

Posts: 28
Joined: 27 Mar 2014, 03:34

C++ API cannot release resource

Postby seeingrain » 29 Jul 2014, 08:51

Call the below code for about 120 times, the system resource used up:
lg_ptrSmartFox=boost::shared_ptr<SmartFox> (new SmartFox());

Why I create the SmartFox instance for so many times? --- Because when a connection attempt failed or lost, I will automatically create a new SmartFox instance and reconnect to server.
I noticed, after calling lg_ptrSmartFox->Version(), the use_count increased to 8, and never decrease, the old SmartFox instance cannot be destroyed even giving a new SmartFox pointer. I investigated the source code of C++ API, it seems because of "shared_from_this()" calling inside of SmartFox.

How to release old SmartFox instance to avoid system resource used up?
User avatar
Site Admin
Posts: 4448
Joined: 29 Mar 2005, 09:50
Location: Italy

Re: C++ API cannot release resource

Postby Bax » 20 Aug 2014, 09:14

Sorry for tho late reply.
We are implementing a method to dispose the SmartFox instance. It will be available in the next version.
Paolo Bax
The SmartFoxServer Team

Return to “SFS2X C++ API”

Who is online

Users browsing this forum: Google [Bot] and 1 guest