Jump to content

[LE] Papyrus: new/garbageCollect


Recommended Posts

Hi everyone,

 

I have a question about the "new" keyword in papyrus

Does it behave like "new" in c++ where you always have to delete manually to prevent memory leaks?

 

so if i do something like this

int[] myArr ;owner is playerAlias aka persisent ref

Event xxEvent
   myArr = new int[10]
   ;do something
Endevent

Event yyEvent
   ;myArr no longer needed
   myArr = none
Endevent

will the pre-reserved memory also be freed or is there a special delete/clear function for arrays?

or will it be garbagecollected like normal variables when leaving scope?

Link to comment
Share on other sites

sure but the point is that the array(s) are declared in script-global scope

the question is if the event runs a second time will

myArr = new int[10]

start the garbage collector or will it simply point to a new memory seg and leave the old data in heap like in c++?

same question for

myArr = none

Link to comment
Share on other sites

Papyrus garbage collection's entirely automatic; as long as you stop references to it, the memory will be deallocated, and if anything goes wrong after you dereference stuff, you can't fix it anyway because there is no way to manually deallocate memory in Papyrus :p

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...