Skip to content

Commit

Permalink
Update freeing-memory.md
Browse files Browse the repository at this point in the history
  • Loading branch information
miparnisari committed Nov 14, 2016
1 parent 34676a7 commit d8c99eb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions v8-tips/freeing-memory.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Freeing memory by assigning `null`

If you want to delete a property of an `Object`, set the property to `null`:
If you want to delete a property of an `Object`, you can set the property to `null`:

```js
// Inefficent way (Bad)
Expand All @@ -12,9 +12,9 @@ var foo = { bar: 'hello world' }
foo.bar = null
```

If you want do delete the `Object` entirely, then simply `foo = null`.
If you want do delete the `Object` entirely, then simply write `foo = null`.

Garbage Collector is interested in `Object`'s that are not referenced by any other `Object`. On the other hand, JavaScript engines can detect such *hot* `Object`'s and attempt to optimize them.
The garbage collector is interested in `Object`s that are not referenced by any other `Object`. On the other hand, JavaScript engines can detect such *hot* `Object`s and attempt to optimize them.

This is easier if the `Object`'s structure doesn’t heavily change over its lifetime. Using `delete` can trigger such changes.

Expand Down

0 comments on commit d8c99eb

Please sign in to comment.