Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Clear Caches/Watchers upon closing a preview #52

Closed
leipert opened this issue Aug 4, 2015 · 2 comments
Closed

Clear Caches/Watchers upon closing a preview #52

leipert opened this issue Aug 4, 2015 · 2 comments
Milestone

Comments

@leipert
Copy link
Contributor

leipert commented Aug 4, 2015

If a preview of a file is closed, we should destroy all things we created for it, like caches or pathwatchers.

Original:

Do we discard the html after preview close, so that it forces a re-render if you re-open it?

Would maybe fix #24 and #49 ?

@Galadirith
Copy link
Collaborator

@leipert The behaviour right now is to simply create a new MarkdownPreviewView whenever a preview is open. Thats the case if a file or editor has never had a preview opened before or previous had.

So unless Atom is doing something interesting under the hood the MarkdownPreviewView along with the html for the preview should be tidied up in garbage collection.

We could explicitly remove the HTML elements associated with the preview from the DOM when the preview is removed by adding some tidy up code here but I don't believe that's going to do any more than Atom already does.

That all said we've got a candidate for fixing #49 in wip #53.

As for #24 removing the HTML won't make a difference. Once the macro's are defined neither MPP or MathJax are actively scanning the source markdown for macro's that are no longer defined. We'd have to manually remove them from MathJax's macro list which is buried somewhere in jax.js which I havn't properly had time to review yet. But monitoring macro's defined in the source markdown does seem to present quite a few problems, implementing a stable parser to identify macros, monitoring ALL open markdown previews as a macro may be undefined in one file but still defined in another, and MathJax macros are global.

I think the best way to handle #24 would be to encourage people to add macros through #14 and extend the functionality of #14 with something like pathwatcher to mirror the user defined macro list file to MathJax's internal macro list, additions and deletions. #14 obviously add's something really important, persistent macro support without cluttering up your markdown document. To be realistic I would want to implement such an extension to #14 for a 2.1.0 release, but if there's time then definitely we'll try to get that in 2.0.0.

Thanks @leipert please let me know if you have any further thoughts on these issues :D

@leipert
Copy link
Contributor Author

leipert commented Aug 6, 2015

Thanks for the long and thorough explanation.

Okay, we dealt with #49.

We just have to have a look for 2.0.0, how we handle #14 in pandoc. We have to add it to each document.

Regarding #24. I think we need a proper garbage collection every time we close a preview. Do the pathwatchers get canceled, what html and images reside in some cache, etc. So I am adjusting this issue to be a base issue to look for garbage we create or where we could shrink the memory footprint of MPP.

@leipert leipert changed the title Discard html after preview close Clear Caches/Watchers upon closing a preview Aug 6, 2015
@leipert leipert added this to the 2.1.0 milestone Aug 6, 2015
@Galadirith Galadirith mentioned this issue Sep 8, 2015
24 tasks
@leipert leipert closed this as completed Sep 8, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants