Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak in SynchronizedConverter #17

Closed
Airex opened this issue Jul 11, 2020 · 3 comments
Closed

Memory leak in SynchronizedConverter #17

Airex opened this issue Jul 11, 2020 · 3 comments

Comments

@Airex
Copy link

Airex commented Jul 11, 2020

in case of using of SynchronizedConverter PdfTools is as singleton and contains _Delegates member that is never cleared and list just fills with delegates on each conversion

_Delegates.Clear(); in DestroyConverter should remove this issue

@xamele0n
Copy link

I purpose to change "delegates" to

 //used to maintain a reference to delegates to prevent them being garbage collected...
private readonly ConcurrentDictionary<IntPtr, List<object>> delegates = new ConcurrentDictionary<IntPtr, List<object>>();

and use

        public void DestroyConverter(IntPtr converter)
        {
            this.delegates.TryRemove(converter, out var l);
            l?.Clear();
            this.module.wkhtmltopdf_destroy_converter(converter);
        }

to free associated delegates

@HakanL
Copy link
Owner

HakanL commented Sep 22, 2020

Please submit PR for review

@HakanL
Copy link
Owner

HakanL commented Oct 7, 2020

I've implemented this now in version 1.3.0, please verify.

@HakanL HakanL closed this as completed Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants