-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18767 from emberjs/fix-mem-leak
[BUGFIX release] Fix observer leaks
- Loading branch information
Showing
49 changed files
with
610 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1 @@ | ||
export { | ||
counters, | ||
deleteMeta, | ||
Meta, | ||
meta, | ||
MetaCounters, | ||
peekMeta, | ||
setMeta, | ||
UNDEFINED, | ||
} from './lib/meta'; | ||
export { counters, Meta, meta, MetaCounters, peekMeta, setMeta, UNDEFINED } from './lib/meta'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Meta, peekMeta } from '@ember/-internals/meta/lib/meta'; | ||
import { assert } from '@ember/debug'; | ||
import { schedule } from '@ember/runloop'; | ||
import { destroyObservers } from './observer'; | ||
|
||
/** | ||
Enqueues finalization on an object so that it can be garbage collected. | ||
Multiple calls will have no effect. | ||
@method destroy | ||
@for Ember | ||
@param {Object} obj the object to destroy | ||
@return {boolean} true if the object went from not destroying to destroying. | ||
@private | ||
*/ | ||
export function destroy(obj: object): boolean { | ||
assert('Cannot call `destroy` on null', obj !== null); | ||
assert('Cannot call `destroy` on undefined', obj !== undefined); | ||
assert( | ||
`Cannot call \`destroy\` on ${typeof obj}`, | ||
typeof obj === 'object' || typeof obj === 'function' | ||
); | ||
|
||
const m = peekMeta(obj); | ||
if (m === null || m.isSourceDestroying()) { | ||
return false; | ||
} | ||
m.setSourceDestroying(); | ||
destroyObservers(obj); | ||
schedule('destroy', m, finalize); | ||
return true; | ||
} | ||
|
||
function finalize(this: Meta) { | ||
this.setSourceDestroyed(); | ||
this.destroy(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.