CroudTech / vue-fullcalendar

FullCalendar Wrapper for vue
MIT License
483 stars 100 forks source link

Memory increase #160

Open OculusMode opened 6 years ago

OculusMode commented 6 years ago

Hey i've been using this library for a while and i found that the memory keeps increasing if i even just toggle it in v-if

sandbox link: https://codesandbox.io/s/5m39v3pj0k

can you help me, that how can i resolve this memory issue(or someways from which i can make sure that GC collects everything of full-calendar. Thanks in advance :)

steven87vt commented 6 years ago

I think I might have just reproduced what you are seeing using just any old dynamic component. Try this and see if you see the same thing I did:

https://codesandbox.io/s/lmlr63qxz

OculusMode commented 6 years ago

@steven87vt yep. you can see leak in this as well if you render full-calender

OculusMode commented 6 years ago

Hey can you please let me know how i can 'destroy' whole calendar? so that the memory which it takes is released as well?

steven87vt commented 6 years ago

I think you can use the standard vue life cycle and let a component be destroyed and recreated as a part of the application workflow. You can also use the $refs attribute to get a reference to the vue-fullcalendar wrapper and use its event listeners to trigger different actions or use its fireMethod helper which allows you to invoke any method in fullcalendar.io.

I would recommend looking at the vue-fullcalendar source so you can see what the different event listeners are doing and review the fullcalendar.io docs for the destroy method, then fireMethod('destroy') away.

On Sat, Oct 6, 2018, 3:16 AM Prashant notifications@github.com wrote:

Hey can you please let me know how i can 'destroy' whole calendar? so that the memory which it takes is released as well?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/CroudTech/vue-fullcalendar/issues/160#issuecomment-427552708, or mute the thread https://github.com/notifications/unsubscribe-auth/ARNAEI4QafWJVda0U9iRLkGganRFJ80uks5uiFjEgaJpZM4Wv2Li .

OculusMode commented 6 years ago

Hello. Thanks for reply. As you suggested, fireMethod('destroy') does the things for me.

However to remove a component in vue js v-if is enough.

But for this library i need to fire destroy method before i remove it from DOM.

So as a proposal can admins add a functionality that whenever someone is removing calender(i.e. may be going to different route) can the library take care of destroying itself?

Currently i need to destroy it when im removing it.

Thanks.

BrockReece commented 6 years ago

Yeah, I think we could use the destroy lifecycle hook for this.

steven87vt commented 6 years ago

Speaking of destroy is keep alive. I believe that parent components on router based keep alive will still destroy. I wonder if destroy would invoke in the following case, and if it does maybe provide an option to enable the feature rather then disable it as the $el ref will change and so would any data stored by reference to this.$refs['fullCalendar].fireMethod('getView'); (etc...). I learned this the hard when when i kept a persisted value in data, post mounted phase, where i cached the this.$refs['fullcalendar'] value and found that every time the suibcomponent was destroyed on route change my references were pointing to the old $el.

app-root.vue:

MyComponent

MyComponent2

FullCalendar.js beforeDestroy() { console.log("fullcalendar destroyed"): }

On Tue, Oct 16, 2018 at 8:24 AM Brock Reece notifications@github.com wrote:

Yeah, I think we could use the destroy lifecycle hook for this.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/CroudTech/vue-fullcalendar/issues/160#issuecomment-430216744, or mute the thread https://github.com/notifications/unsubscribe-auth/ARNAEMPtRwmZjkRHSvpfxOedVnkr0I_Cks5ulc_qgaJpZM4Wv2Li .