| 03-16-2005, 11:51 PM | #1 |
It's a very short question. I was just wondering if setting 220 items in a variable array might cause some players to experience lag. I'd call one function which would set the variables at once. Would it be faster if I cached them, or it just won't change a thing? -CTM ![]() |
| 03-17-2005, 12:09 AM | #2 |
Try both ways. You might also get a memory leak.... Dangerous... Lol. |
| 03-17-2005, 12:14 AM | #3 |
I need these variables throughout the game though... =/ I can't unset them everytime I use them :P |
| 03-17-2005, 12:16 AM | #4 |
Uh makes things worse... I think you might have to stick it out... |
| 03-17-2005, 12:19 AM | #5 |
It's really going to take that much place? Maybe I ought to save them in a game cache then? And erase the cache at the end of the game I presume. |
| 03-17-2005, 01:09 AM | #6 |
No, setting stuff to arrays/integers/whatevers will NOT make the game lag. I repeat. Will NOT. Setting variables is a one step processing thing. Things that make the game lag take a lot of processing power, like special effects and such things. |
| 03-17-2005, 07:36 AM | #7 |
set statements use so little processing power it would take a lot more to cause any lag and contrary to previous postings, it won't cause a memory leak |
| 03-17-2005, 09:08 PM | #8 |
Well I'm glad I can use my method then :) |
| 03-17-2005, 09:21 PM | #9 |
Just be cautious when you do it, because you might experience memory leaks, which causes lag, and such... |
| 03-17-2005, 09:39 PM | #10 | ||
Quote:
Quote:
Believe me ... Raptor-- is right. No memory leaks will be experianced unless you do something else. |
| 03-18-2005, 01:47 AM | #11 | |
Quote:
like i said, this is not true little info: memory leaks occur when new objects are created, and then their reference is lost before their deconstructor is called, hence leaving an object in memory with no way to access it since arrays of reference variables (ie units, items -- basically any non-primative) ony store a copy of the reference to the object, they do not create new objects everytime you 'set' a variable to an object now, while the array will take up a set amount of memory, it won't leak since any new references made will override old ones, also, items are always kept in reference by the game (otherwise it wouldn't be able to do anything to them) and once an item is destroyed, its deconstructor is called therefore freeing up the memory -- when this happens, the array may still contain a reference, but it won't contain a separate object hence it doesn't take up any more memory to give you a more full understanding, (note, this is to my knowledge only, it may work a bit different, but the principle is the same) the reason locations (points) will leak and have to be cleaned up is because when you say 'Create unit at (centre of region001)' the game automatically makes a new 'point' object for you that contains the coordinates for the centre of region001, and then immediately uses it to create a unit there, except once thats done it discards the reference to the point -- thus we have a point object floating in memory and we have no way of accessing that piece of memory -- memory leak when we destroy leaks by setting a variable to this, what we are doing is making a copy of the variable reference, and holding it in our own piece of memory, that points to this 'point' block of memory. so once war3 discards its reference to the 'point' we still have a copy if it, hence we can say "RemoveLocation( variable )" in order to destroy that piece of memory we referenced |
