Particles System with a little memory leak...
2 posters
Particles System with a little memory leak...
Hi guys, i was implementing the particles system in my game when i found this memory leak, but its easy to correct...
In the sio2_emitter.cc in the sio2EmitterRender method replace:
to
and just for precaution replace too in the same method:
to
If you put the line below in the themplate.mm in the first line of particle_render method on tutorial12, you will see what iam saying...
I hope to helped someone...
In the sio2_emitter.cc in the sio2EmitterRender method replace:
- Code:
++_SIO2emitter->n_particle
to
- Code:
if (_SIO2emitter->n_particle < _SIO2emitter->maxp - 1) {
++_SIO2emitter->n_particle
}
and just for precaution replace too in the same method:
- Code:
--_SIO2emitter->n_particle
to
- Code:
if (_SIO2emitter->n_particle > 0) {
--_SIO2emitter->n_particle
}
If you put the line below in the themplate.mm in the first line of particle_render method on tutorial12, you will see what iam saying...
- Code:
printf("%d\n", _SIO2emitter->n_particle);
I hope to helped someone...
Re: Particles System with a little memory leak...
Hummmm I don't know but I test in tutorial12 with the original code again with MallocGuard and Instruments Leaks and there's no leak whatsoever...
Can you please double check?
Tks!
Can you please double check?
Tks!
Re: Particles System with a little memory leak...
Did you inserted the line that i sugested in tutorial12 render method to print the number of particles? You will see for example that fire has a maxp = 60, but after some renders (about 200) the number of particles keep increasing... and how the number of particles can be greater than maxp? Maybe i'am crazy, but im my game without the changes that i sugested, the particles stop to render in about 5 seconds...
Re: Particles System with a little memory leak...
Hummmm not sure what is wrong with your implementation but for me no element of the _SIO2emitter->_SIO2particle is accessed with a value higher than the maxp... You have to take note that _SIO2emitter->n_particle, is the current particle number and because of the n_particle = ( unsigned int )( _SIO2emitter->sync_time / _SIO2emitter->pps ); approximation it might go up a bit or down a bit compare to maxp which is 100% normal... _SIO2emitter->n_particle is an approximation of the current number of activated particles and in no way this will create leaks or access an element array that have not been initialized...
Add this line to verify it:
if( j >= _SIO2emitter->maxp )
{
printf("%d:%d\n", j, _SIO2emitter->n_particle);
}
Add this line to verify it:
if( j >= _SIO2emitter->maxp )
{
printf("%d:%d\n", j, _SIO2emitter->n_particle);
}
Re: Particles System with a little memory leak...
Really... i saw that... but why it's crashing i don't know yet...
Re: Particles System with a little memory leak...
I've discovered... it's why i was using ((SIO2emitter*)_ptr)->n_particle on render method for performance meter and it's have a number greater than ((SIO2emitter*)_ptr)->maxp after some time without my changes on sio2EmitterRender now... i don't know if it's correct or not... you tell me...
Re: Particles System with a little memory leak...
It is correct... You must have a leak somewhere else use mallocguard and leaks...
Similar topics
» leak of memory
» sio2Free will make the memory leak????
» 2d particles
» Particles and emitters
» Particles Question
» sio2Free will make the memory leak????
» 2d particles
» Particles and emitters
» Particles Question
Permissions in this forum:
You cannot reply to topics in this forum