Crash while push back objects -
RyDeR` - 16.08.2010
Hi,
this is the way I let create my objects in C++:
Код:
static cell AMX_NATIVE_CALL Core_CreateStreamedObject(AMX * amx, cell * params)
{
Object object;
object.objectID = params[1];
object.x = amx_ctof(params[2]);
object.y = amx_ctof(params[3]);
object.z = amx_ctof(params[4]);
object.rx = amx_ctof(params[5]);
object.ry = amx_ctof(params[6]);
object.rz = amx_ctof(params[7]);
object.distance = amx_ctof(params[8]);
objects.push_back(object);
return 0;
}
When I'm over 250.000 objects samp-server.exe crashes while creating. Why?
When I delete "objects.push_back(object);" it doesn't crash and it creates as much as you want but you can't see them ingame.
Re: Crash while push back objects -
pliva_sb - 16.08.2010
Well,you can't push_back the struct.Try to use iterator and get last element of vector.
Re: Crash while push back objects - Zeex - 16.08.2010
If "objects" is a vector, try the following
Код:
// call when plugin gets loaded
objects.reserve(n);
where n is the maximum number of objects you're gonna create. This will allocate enough space for n elements inside the vector and it won't grow and re-allocate memory while you're adding the objects (should also increase performance btw). If it still fails, you may also try using a static array instead of container.
Re: Crash while push back objects -
pliva_sb - 16.08.2010
Quote:
Originally Posted by ******
You can push back whatever you want. However it may be a memory limitation. And I said this to someone else - why release (or even make) yet another streamer with no obvious improvement over existing streamers?
|
Then he must to define vector like <str> or even my bad?
Answer: He wants to improve his streamer into the plugin and also to create unlimited.
Re: Crash while push back objects -
RyDeR` - 16.08.2010
pliva_sb:
Thanks for your responses man but can you maybe give a little bit more info about what you mean?
******:
I totally agree but it's always nice to have something you made yourself for own usage in my opnion.
Zeex:
Thanks, worked but still can't go unlimited - When I reserve more than 1.000.000 samp-server.exe even don't start.
I have no idea how to fix this.
My point was to get this streamer streaming unlimited objects. First I worked with array sizes which was very bad because I couldn't go over 700.000. I asked Incognito in PM he told me to do in this way so I did. My streamer works perfect just when I create more then 'x' amount it crashes.
I hope someone can give me a solving answer to this problem, please ask if you need more info about this to solve.
Re: Crash while push back objects -
RoBo - 16.08.2010
Quote:
Originally Posted by ******
You can push back whatever you want. However it may be a memory limitation. And I said this to someone else - why release (or even make) yet another streamer with no obvious improvement over existing streamers?
|
None of them are especially fast or customisable, but would probably be fine for 95% of servers.