-
Notifications
You must be signed in to change notification settings - Fork 94
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
Possible memory leak? #24
Comments
No, the pointer |
Oh, my fail! Thanks. |
And get deleted, if you call MoveDynamicObject 2-3 timer, before object finished moving? Because i have not saw any delete here. Now i understood, If object has finished moving, o->second->move wil be deleted. But this should be deleted if somebody calls 2-3times MoveDyanmicObject before object finished moving and use just 1 pointer. (delete last pointer, allocate new) |
It's an |
@samp-incognito It is not accurate, (*o)->move.reset(); That destroying the pointer. About @kurta999 comment: If you calling More information can be found on wikipedia: http://en.wikipedia.org/wiki/Smart_pointer |
Yes, that's correct. When I mentioned the In any case, this isn't a memory leak, but thanks for reviewing the code anyway. |
I'm boread, and I checked your streamer.
In MoveDynamicObject I found something interesting..
cell AMX_NATIVE_CALL Natives::MoveDynamicObject(AMX *amx, cell *params)
{
CHECK_PARAMS(8, "MoveDynamicObject");
if (!amx_ctof(params[5]))
{
return 0;
}
boost::unordered_map<int, Item::SharedObject>::iterator o = core->getData()->objects.find(static_cast(params[1]));
if (o != core->getData()->objects.end())
{
if (o->second->attach)
{
sampgdk::logprintf("MoveDynamicObject: Object is currently attached and cannot be moved");
return 0;
}
Eigen::Vector3f position(amx_ctof(params[2]), amx_ctof(params[3]), amx_ctof(params[4]));
Eigen::Vector3f rotation(amx_ctof(params[6]), amx_ctof(params[7]), amx_ctof(params[8]));
o->second->move = boost::intrusive_ptrItem::Object::Move(new Item::Object::Move);
o->second->move->duration = static_cast((static_cast(boost::geometry::distance(position, o->second->position) / amx_ctof(params[5])) * 1000.0f));
o->second->move->position.get<0>() = position;
o->second->move->position.get<1>() = o->second->position;
o->second->move->position.get<2>() = (position - o->second->position) / static_cast(o->second->move->duration);
o->second->move->rotation.get<0>() = rotation;
if ((o->second->move->rotation.get<0>().maxCoeff() + 1000.0f) > std::numeric_limits::epsilon())
{
o->second->move->rotation.get<1>() = o->second->rotation;
o->second->move->rotation.get<2>() = (rotation - o->second->rotation) / static_cast(o->second->move->duration);
}
o->second->move->speed = amx_ctof(params[5]);
o->second->move->time = boost::chrono::steady_clock::now();
for (boost::unordered_map<int, Player>::iterator p = core->getData()->players.begin(); p != core->getData()->players.end(); ++p)
{
boost::unordered_map<int, int>::iterator i = p->second.internalObjects.find(o->first);
if (i != p->second.internalObjects.end())
{
StopPlayerObject(p->first, i->second);
MovePlayerObject(p->first, i->second, o->second->move->position.get<0>()[0], o->second->move->position.get<0>()[1], o->second->move->position.get<0>()[2], o->second->move->speed, o->second->move->rotation.get<0>()[0], o->second->move->rotation.get<0>()[1], o->second->move->rotation.get<0>()[2]);
}
}
core->getStreamer()->movingObjects.insert(o->second);
return static_cast(o->second->move->duration);
}
return 0;
}
o->second->move = boost::intrusive_ptrItem::Object::Move(new Item::Object::Move);
There is a memory leak, isn't? Because you never delete this pointer.
The text was updated successfully, but these errors were encountered: