object1 as a property of object2 which is in turn a property of object1 - will result in memory leak?

前端 未结 1 421
北海茫月
北海茫月 2021-01-16 01:55

Will \"form\" and \"form.errorProcessor\" just hold single references to each other and have only 2 objects in memory, or is this a leak / problem situation?



        
相关标签:
1条回答
  • 2021-01-16 02:18

    No, there is no memory leak caused by circular references, and you are creating only two objects in your code. Any decent garbage collector can handle them.

    The only problem is when you recursively inspect your object (like you do with expanding its properties in the console), you go down a bottomless pit - if done programmatically, you'd get an infinite loop or stack overflow from recursion. All these structures you see in your console are representing the same object, though.

    0 讨论(0)
提交回复
热议问题