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 with Printing C# Sample? #333

Closed
laviassister opened this issue Mar 24, 2016 · 25 comments
Closed

Memory leak with Printing C# Sample? #333

laviassister opened this issue Mar 24, 2016 · 25 comments

Comments

@laviassister
Copy link

For a Printing C# Sample for Uiversal Windows Application

  1. build
  2. select the scenario4 , push PrintSelection , canceled after the print preview came out
  3. select the scenario5 , push Print , canceled after the print preview came out
  4. Repeat 10 times 2)-3)
    result, a large amount of memory is leaked.
    Whether there is a problem in procedure of calling the sample
    , or the bug of Windows 10?
@jajamatu
Copy link

Hi,

I have the same issue with the provided printing scenario and I would be very happy if somebody could tell me how to avoid the memory overflow.
I have just started learning programming with uwp this year - but this Problem tracks me already for more than 5 hard and frustrating weeks of trying to get a head on it.

I have programmed a little app where the user can easily create a purchase list with different products.
Now I want to implement the option that the user can also print this list. This is necessary beacuseof different reasons.

Therefore I have studied the Scenario 1 of the provided printing sample.
But when I run this example on my Lumia 650 the app gets a Memory Overflow by operating like this:

  1. Select Scenario 1 and press the button for printing
  2. cancel the upcoming printpreview
  3. select Scenario 2 without doing anything else (just to unregister the Printer outof Scenario 1)
  4. select once again Scenario 1 and repeat the procedure for 9-12 times

The same behavior can be monitored with the Lumia 950 - even if it takes more times of repeats to get the exception thrown becauseof the greater memory.

By catching the thrown exception I get the message:
"Insufficient memory to continue the execution of the program."
HResult: -2147024882

This exception is thrown in the procedure getPrintPreviewPage(...) before this code-line is executing:
"printDoc.SetPreviewPage(e.PageNumber, printPreviewPages(e.PageNumber - 1))"

I'm really desperate because I have already tried so much to avoid this Memory leak with different attempts.
But nothing works.
And I don't find the object that is responsible for the Overflow.

Maybe someone could help me to solve this Problem?

Kind regards from Germany,
Janine

@oldnewthing
Copy link
Member

I've asked the feature team to investigate.

@oldnewthing
Copy link
Member

The feature team has confirmed a memory leak. They are working to fix it. Thanks for reporting.

@laviassister
Copy link
Author

Thank you for fixing!

@rueldognidon-erni
Copy link

I am still encountering this Memory Leak, I believe we need to repopen this issue since the fix is still not in place.

@oldnewthing
Copy link
Member

Yes, the feature team is working on the fix. The memory leak is not due to a bug in the sample, so the samples issue remains closed. You are welcome to open a Feedback Hub item to report the platform issue.

@ryancairnsy
Copy link

We have recently discovered this bug is causing major problems on our kiosk mode LOB app because of the increase in memory every time the users print (the app does not get restarted). Is there anywhere else I can log this as an issue to try and get updates on progress etc?

@oldnewthing
Copy link
Member

You can open a Feedback Hub item. I think "Developer Platform" is the category.

@ryancairnsy
Copy link

Thanks - I have done that now. https://aka.ms/AA22cmx

@jeanmarc3
Copy link

I'm having the same issue but can't find where this fix has been posted. Any help?

@ryancairnsy
Copy link

ryancairnsy commented Nov 13, 2018 via email

@jeanmarc3
Copy link

Thanks Ryan for the answer. It is a bit scary that Microsoft seems to drop UWP support completely (starting with Office apps...). Did you end up writing your own print preview screen, or just do like Scenario 6 or the sample app?

@ryancairnsy
Copy link

ryancairnsy commented Nov 13, 2018 via email

@jeanmarc3
Copy link

This print issue exists since 2016. Also:
https://winbuzzer.com/2018/09/28/microsoft-explains-why-it-is-ending-office-uwp-app-feature-support-xcxwbn/?fbclid=IwAR2zQKZwhXE2oXDyMgf8EExKUgZKRlDkPbbbO5ZUdgl4s1zFqGUU6VuShCU

@zanamziry
Copy link

its almost 2021 and they still didn't resolve this issue, print 10 pages and 1GB is wasted...

@michaelrinderle
Copy link

i will say the same. still not fixed. what are UWP developer to do with this? any pointers on certain parts of the code that we can make sure their objects are getting destroyed by explicit garbage collection? ive tried everything and this is a huge leak. customers are expecting to have a print preview dialog.

@baskren
Copy link

Why is this closed - it's well into 2021 and this is definitely not fixed.

@oldnewthing
Copy link
Member

Because it's not a bug in the sample. It's a bug in the OS.

@michaelrinderle
Copy link

i'll re-phrase for @baskren :
why hasn't this been passed on to the OS devs in over 4 years?

@baskren I had to drop print preview report because I wouldn't let the app go into the wild with this leak. I opted to just download the PDF and launch from the default pdf program.

@baskren
Copy link

@oldnewthing: Thanks for confirming. My angst was (slightly) misdirected.

@michaelrinderle : Yes, I've had to disable printing on 32 bit builds because of this.

@baskren
Copy link

baskren commented Mar 4, 2021

@oldnewthing : Should have added one more thing ... per your Aug 15, 2018 comment

You can open a Feedback Hub item. I think "Developer Platform" is the category.

I can't say how much I wish this was helpful. It's almost as if Feedback Hub is where all well intentioned issues go to die. Is there any chance there is a GitHub repo that we could report this issue?

@oldnewthing
Copy link
Member

Why hasn't this been passed on to the OS devs in over 4 years?

I forwarded it to them when the issue was opened in 2016 but never heard back. I went and kicked the thread again.

@baskren
Copy link

baskren commented Mar 5, 2021

@oldnewthing : I would be happy to provide a demo project and submit a bug report / issue ... if I knew it was going to be seen and be helpful to the devs.

edit: Is there a github repo where I could do that?

@pratikpc
Copy link

@baskren this was apparently fixed in Windows 11 Insider Preview Build 22000.65

I guess @oldnewthing forwarding it again led to it getting fixed

https://blogs.windows.com/windows-insider/2021/07/08/announcing-windows-11-insider-preview-build-22000-65/

@baskren
Copy link

@pratikpc - Thank you for closing the thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants