# Memory leak risk \[SOLVED\]

**URL:** <https://discuss.prosemirror.net/t/memory-leak-risk-solved/1732>\
**Category:** Uncategorized\
**Created:** [January 10, 2019, 6:17am UTC](https://discuss.prosemirror.net/t/memory-leak-risk-solved/1732 "2019-01-10T06:17:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alecyrus](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/alecyrus/32/842_2.png) [@Alecyrus](https://discuss.prosemirror.net/u/Alecyrus)\
**Post date:** [January 10, 2019, 6:17am UTC](https://discuss.prosemirror.net/t/memory-leak-risk-solved/1732/1 "2019-01-10T06:17:01Z")

</div>

When I use ProseMirrorEditor in my component, if I switch the component by changing the routes page frequently. I found the number of editor component instance could increase with the routes changing. Once I comment all ProseMirrorEditor code, the memory usage falls down. Recently I realize the memory management is very important because the memory leak of my APP, so i start to assess the potential memory leak risk of every 3-rd party component I used.

related destroy code:

```javascript
  beforeDestroy() {
    this.editor.view.destroy();
    this.editor.state = null;
    this.editor.view = null;
  },

```

The following is timeline analysis. enter the ProseMirrorEditor component &amp reenter ProseMirrorEditor componen

 ![image](https://discuss.prosemirror.net/uploads/secondsite/original/1X/e6ab8bcb36bef76fc860d8983cb1d523fcd74db4.png)

How should I do to prevent from memory leaking? I think it may be my mistake. but the code is very simple, create the editor and destroy the editor in the Hook function (I use VueJS to develop my APP)

---

<div class="post-metadata">

**Author:** ![Alecyrus](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/alecyrus/32/842_2.png) [@Alecyrus](https://discuss.prosemirror.net/u/Alecyrus)\
**Post date:** [January 10, 2019, 6:28am UTC](https://discuss.prosemirror.net/t/memory-leak-risk-solved/1732/2 "2019-01-10T06:28:02Z")

</div>

My mistake…GC work perfectly

![image](https://discuss.prosemirror.net/uploads/secondsite/original/1X/70fb12149739ffab1a43d9f8a9deb8288f5fc96a.png)
