pruiz / WkHtmlToXSharp

C# wrapper wrapper (using P/Invoke) for the excelent Html to PDF conversion library wkhtmltopdf library.
239 stars 83 forks source link

CallbackOnCollectedDelegate MDA #37

Open ilyazolotarov opened 7 years ago

ilyazolotarov commented 7 years ago

Sometimes when a system is under heavy load CallbackOnCollectedDelegate occur and produce NullReferenceException. The reason is that in the method WkHtmlToPdfConverter._Convert native calls that are invoked in the finally block (wkhtmltopdf_set_error_callback (converter, null), etc.) do not have time to work on the side of c ++ library before the garbage collector destroys corresponding delegates objects. In particular case it tries to call wkhtmltopdf_int_callback after completion of the WkHtmlToPdfConverter._Convert method that resulted in an error.

pruiz commented 7 years ago

Hi,

Do you have any proposed fix, or any way of reproducing the issue?

Regards Pablo

Sent from my iPhone

On 15 Nov 2016, at 10:29, ilyazolotarov notifications@github.com wrote:

Sometimes when a system is under heavy load CallbackOnCollectedDelegate occur and produce NullReferenceException. The reason is that in the method WkHtmlToPdfConverter._Convert native calls that are invoked in the finally block (wkhtmltopdf_set_error_callback (converter, null), etc.) do not have time to work on the side of c ++ library before the garbage collector destroys corresponding delegates objects. In particular case it tries to call wkhtmltopdf_int_callback after completion of the WkHtmlToPdfConverter._Convert method that resulted in an error.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.