Posts: 54
Threads: 19
Joined: Apr 2013
Reputation:
0
Hi which of static/new use less stack/heap memory in a function?
Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
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.
Posts: 54
Threads: 19
Joined: Apr 2013
Reputation:
0
Ok thanks a lot i will use new in my case.
Posts: 4,878
Threads: 85
Joined: Jun 2007
Reputation:
0
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.