SA-MP Forums Archive
static or new - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: static or new (/showthread.php?tid=505311)



static or new - andyandyy8 - 07.04.2014

Hi which of static/new use less stack/heap memory in a function?


Re: static or new - Vince - 07.04.2014

They both require the same space. The only difference is that static acts like a global variable and retains its value between function calls whereas new reinitializes the variable every time.


Re: static or new - andyandyy8 - 07.04.2014

Ok thanks a lot i will use new in my case.


Re: static or new - MP2 - 07.04.2014

----


Re: static or new - Mauzen - 07.04.2014

Keeping the stack small isnt a bad idea, but as said, isnt as essential as it was 15 years ago.
In theory statics are faster when used repetitive, as they dont need to be pushed again and again. Dont know how well pawn does that though.