undefined
undefined

Reputation: 6884

JS function properties and memory

Let's say I have a function with a static property, for example:

function Test() {}

Test.someProp = bigObject;

I'm wondering if bigObject will always be in memory or it will gc sometime?

Upvotes: 1

Views: 36

Answers (1)

JohnPan
JohnPan

Reputation: 1210

It will never be collected as long as someProp is alive (has a reference). If you delete Test.someProp or delete or empty the whole Test then it will be gCollected

Upvotes: 1

Related Questions