playMaker

Author Topic: Array(inspector on) in RunFSM cases GC  (Read 258 times)

human890209

  • Junior Playmaker
  • **
  • Posts: 60
    • View Profile
Array(inspector on) in RunFSM cases GC
« on: August 28, 2017, 05:42:01 PM »
Hi,
I'm a heavy RunFSM user. And I've found that if I make some Arrays with inspector turned on in a Fsm Template (Exposed as inputs for RUNFSM). That will cause GC during running. I think it maybe happens in the fsm.updatevalue() or fsm.applyoverride() (I can't remember the method name, something about override). That is not cool for RunFSM during an ArrayGetNext or Iterate Loop. Hope you could solve this problem and keep optimizing the RunFSM. Bolt seems to do well in macros and reflection, I hope playmaker could be better. For now, I use a string variable to pass an array name to let the FsmTemplate GetFSMArray, that will save most GC as a walk around. But which is not so Convenient to use. I think Playmaker's best parts are User-Friendly, Convenient, EditSpeed, and  No Performance Issues at most situations. Hope the RunFsm's Performance and Nested Output could be improved and make Playmaker the best VisualScripting tools in the future. ;)
« Last Edit: August 28, 2017, 05:43:35 PM by human890209 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12098
  • Official Playmaker Support
    • View Profile
Re: Array(inspector on) in RunFSM cases GC
« Reply #1 on: August 29, 2017, 12:30:13 AM »
Hi,

this is fine, because all of this only happens when in Editor, not when published.

what do you mean by nested output?

Bye,

 Jean

human890209

  • Junior Playmaker
  • **
  • Posts: 60
    • View Profile
Re: Array(inspector on) in RunFSM cases GC
« Reply #2 on: August 29, 2017, 02:26:11 AM »
Hi Jean,
I've done some test, I think the GC is caused by fsmArray.resize() during fsm.UpdateValue(), Are you sure it will be fine when published? it seems any Array Action contains fsmArray.resize() will cause some GC and during a loop(50times/frame) it will be a Huge GC.

Nested FSM Output is an old topic about send output variable to FatherFSM. For now, FsmSon could send variables to FsmFather, but FsmGrandson can't send variables to FsmSon, cause it's host Fsm is targeted to FsmFather.

 

human890209

  • Junior Playmaker
  • **
  • Posts: 60
    • View Profile
Re: Array(inspector on) in RunFSM cases GC
« Reply #3 on: August 29, 2017, 11:27:48 PM »
Hi Jean,
I build the test scene with development build, run it on an android phone and Profile it with UnityProfiler. I test Both Using InspectorArray Directly and Using InspectorArrayName and GetFsmArray in FSM Template. It shows that InspectorArray generates 6-7 times GC than the ArrayName solution.

human890209

  • Junior Playmaker
  • **
  • Posts: 60
    • View Profile
Re: Array(inspector on) in RunFSM cases GC
« Reply #4 on: August 31, 2017, 10:48:15 PM »
Hi,
I also find array.resize(0) in GetFsmArray and SetFsmArray, I'm wondering why will resize to 0 before setting to another array.value? I've tested that it still works without array.resize(0). Does array.resize(0) release memory or something?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12098
  • Official Playmaker Support
    • View Profile
Re: Array(inspector on) in RunFSM cases GC
« Reply #5 on: September 01, 2017, 02:44:17 AM »
Hi,

 Yeah, it looks this needs optimizing indeed. I'll have a look and propose improvments for an update.

however, be aware indeed that you should use ArrayMaker for more flexibility, because the Built in Array in terms of performances is meant to not have it's size changes as it implies GC in all cases, so if you have some performances issue on that front, I would suggest trying out ArrayMaker which uses lists and they don't take GC that much ( or at least I can do something about it straight away as I authored it).

Bye,

 Jean