Author Topic: Passing Variables Versus Retrieving Variables  (Read 421 times)

Legacy_virusman

  • Sr. Member
  • ****
  • Posts: 448
  • Karma: +0/-0
Passing Variables Versus Retrieving Variables
« Reply #15 on: December 11, 2013, 12:01:48 pm »


               For a 20-byte structure, you'd have to leak it 2.5 million times to see a noticeable (50MB) memory bump. That's running a server for 29 days with a pseudo heartbeat that's called every second.
               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Passing Variables Versus Retrieving Variables
« Reply #16 on: December 11, 2013, 04:48:05 pm »


               Is the memory leak a permanent one or one that lasts until the script ends?  Not sure how good the "garbage collector" for NWN might be if it even exists.

Also, does this happen each and every time a location/effect/item property/talent is passed to a function or only if it is passed multiple times recursively?  And how does it this interact with built-in functions like GetDistanceBetweenLocations (does that always trigger two memory leaks)?

Does returning one of these also cause an issue or only passing as an argument?
               
               

               
            

Legacy_leo_x

  • Sr. Member
  • ****
  • Posts: 403
  • Karma: +0/-0
Passing Variables Versus Retrieving Variables
« Reply #17 on: December 11, 2013, 09:31:14 pm »


                Pretty sure the memory leak in question is only from an engine structure being passed as an argument to the function argument of DelayCommand, AssignCommand, and ActionDoCommand.  That's how I've interpreted it.  These types of memory leaks would persist until the nwserver process exited, basically they're mallocs without frees
               
               

               


                     Modifié par pope_leo, 11 décembre 2013 - 09:37 .
                     
                  


            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Passing Variables Versus Retrieving Variables
« Reply #18 on: December 13, 2013, 09:16:34 pm »


               Good to know, thanks, I'll make sure I avoid those as much as possible.