evanpage Posted February 13, 2017 Share Posted February 13, 2017 Okay so before I get told I checked the pinned post regarding 'out of memory' errors. I've been getting 'Not Enough Memory to Paste from Clipboard' quite a lot recently. As of this moment I am trying to copy a 443x312 jpg and paste into paint.net. I am using ~35% of my total 16GB RAM. I have over 10GB of free drive space on C: I'm running Win10 64-bit. Why is this happening? ======= Error log: ======= System.OutOfMemoryException: Out of memory. at System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorManagement) at PaintDotNet.ClipboardUtil.GetClipboardImageAsSurface(IWin32Window currentWindow, IPdnDataObject clipData) in D:\src\pdn\src\PaintDotNet\ClipboardUtil.cs:line 352 at PaintDotNet.ClipboardUtil.GetClipboardImageImpl(IWin32Window currentWindow, IPdnDataObject clipData) in D:\src\pdn\src\PaintDotNet\ClipboardUtil.cs:line 215 at PaintDotNet.ClipboardUtil.GetClipboardImage(IWin32Window currentWindow, IPdnDataObject clipData) in D:\src\pdn\src\PaintDotNet\ClipboardUtil.cs:line 164 at PaintDotNet.Actions.PasteAction.PerformActionImpl() in D:\src\pdn\src\PaintDotNet\Actions\PasteAction.cs:line 110 Quote Link to comment Share on other sites More sharing options...
MJW Posted February 14, 2017 Share Posted February 14, 2017 I just got the error trying to Paste into New Image an image from the Average Object Color thread. The image: The error message: System.OutOfMemoryException: Out of memory. at System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorManagement) at PaintDotNet.ClipboardUtil.GetClipboardImageAsSurface(IWin32Window currentWindow, IPdnDataObject clipData)in D:\src\pdn\src\PaintDotNet\ClipboardUtil.cs:line 352 at PaintDotNet.ClipboardUtil.GetClipboardImageImpl(IWin32Window currentWindow, IPdnDataObject clipData) in D:\src\pdn\src\PaintDotNet\ClipboardUtil.cs:line 215 at PaintDotNet.ClipboardUtil.GetClipboardImage(IWin32Window currentWindow, IPdnDataObject clipData) in D:\src\pdn\src\PaintDotNet\ClipboardUtil.cs:line 164 at PaintDotNet.Actions.PasteInToNewImageAction.PerformAction(AppWorkspace appWorkspace) in D:\src\pdn\src\PaintDotNet\Actions\PasteInToNewImageAction.cs:line 46 According to the Task Manager, I have about 3 GB of free memory. Quote Link to comment Share on other sites More sharing options...
Red ochre Posted February 14, 2017 Share Posted February 14, 2017 Pdn 4.0.13 Just copied MJW's sunflower image (latest firefox/right click/ copy image) - opened Pdn with a view to creating a new image and pasting. Didn't get that far as Pdn locked up. Cursor still moved but no controls worked - including minimize and close. Closed it using task manager. No 'program not responding message'. No error message, No crash report, just 'froze'? Tried a second time and I get the same out of memory error message as above. All these crash reports mention 'useEmbeddedColorManagement' but I thought Pdn didn't use that anyway? Solved (for me) Disabled the Pinterest Firefox plugin. Quote Red ochre Plugin pack.............. Diabolical Drawings ................Real Paintings Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted February 14, 2017 Share Posted February 14, 2017 5 hours ago, Red ochre said: Just copied MJW's sunflower image (latest firefox/right click/ copy image) I got as far as trying to paste the image... Spoiler System.OutOfMemoryException: Out of memory. at System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorManagement) at PaintDotNet.ClipboardUtil.GetClipboardImageAsSurface(IWin32Window currentWindow, IPdnDataObject clipData) in D:\src\pdn\src\PaintDotNet\ClipboardUtil.cs:line 352 at PaintDotNet.ClipboardUtil.GetClipboardImageImpl(IWin32Window currentWindow, IPdnDataObject clipData) in D:\src\pdn\src\PaintDotNet\ClipboardUtil.cs:line 215 at PaintDotNet.ClipboardUtil.GetClipboardImage(IWin32Window currentWindow, IPdnDataObject clipData) in D:\src\pdn\src\PaintDotNet\ClipboardUtil.cs:line 164 at PaintDotNet.Actions.PasteAction.PerformActionImpl() in D:\src\pdn\src\PaintDotNet\Actions\PasteAction.cs:line 110 Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
null54 Posted February 14, 2017 Share Posted February 14, 2017 As toe_head2001 stated earlier in this thread: On 2/13/2017 at 2:42 AM, toe_head2001 said: A few other people have reported the same issue. It's not actually a memory issue, but rather an issue with the image format. The Image.FromFile method throws an OutOfMemoryException when it does not support loading the image. From MSDN: Quote If the file does not have a valid image format or if GDI+ does not support the pixel format of the file, this method throws an OutOfMemoryException exception. Quote Plugin Pack | PSFilterPdn | Content Aware Fill | G'MIC | Paint Shop Pro Filetype | RAW Filetype | WebP Filetype The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait Link to comment Share on other sites More sharing options...
toe_head2001 Posted February 14, 2017 Share Posted February 14, 2017 (edited) I looked into the issues this morning. TL;DR: Firefox's fault. It's saving HTML as a PNG image. Ok, I guess it's PhotoBucket's fault too, because they are redirecting requests to the PNG image to an HTML page. While Firefox places several formats on the clipboard (including valid Bitmaps/DIBs), paint.net ends up trying to load an invalid PNG image. Too bad the image is actually HTML code saved as a PNG. Here's the PNG file on the clipboard: And here's the content of the "PNG" file: Chromium based browsers (Chrome, Vivaldi, ect.) don't place so many formats on the clipboard, so paint.net ends up loading the Bitmap/DIB, thus avoiding the issue of PhotoBucket redirecting requests to PNG images. Edited January 31, 2021 by toe_head2001 fixed broken images 1 Quote My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
MJW Posted February 22, 2017 Share Posted February 22, 2017 Microsoft Paint seems to have no problem pasting the images that PDN gives the memory error on. I copied my flower image to the clipboard and tried pasting into PDN. I got the "not enough memory" error. I then went to an open MS Paint window and clicked the Paste button. The image was immediately pasted. I tried with a different image, with the same result. If there's a problem with the image data in the clipboard, it's a problem MS Paint can deal with. Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted February 22, 2017 Share Posted February 22, 2017 I suspect MS Paint is either: 1) just using the DIB and not trying any of the other formats first 2) using the DIB after it attempts to use the PNG file. Quote My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
MJW Posted February 22, 2017 Share Posted February 22, 2017 One thing I just realized is that I can use the problematic clipboard images in plugins that use the clipboard, such as the Texture Shader and Texture Merger. So, if PDN can identify it's supposed to be a PNG image, and if PDN can access the data, isn't it better to fix it to work, even if it's technically Firefox's problem? Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted February 22, 2017 Share Posted February 22, 2017 2 hours ago, MJW said: So, if PDN can identify it's supposed to be a PNG image, and if PDN can access the data, isn't it better to fix it to work, even if it's technically Firefox's problem? Personally, yes, I think a workaround would be ideal. In my previous post, I should have said something more like: "It's an issue in Firefox that exposes a limitation of paint.net". Paint.net is just weird about selecting a format from the clipboard. I've brought this up before: http://forums.getpaint.net/index.php?/topic/31799-selecting-a-format-from-the-clipboard/ Quote My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
BoltBait Posted February 22, 2017 Share Posted February 22, 2017 Rick is unlikely to change his clipboard handling code. Any changes made would mean trade-offs that he's unwilling to make. Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
Rick Brewster Posted February 22, 2017 Share Posted February 22, 2017 10 hours ago, BoltBait said: Rick is unlikely to change his clipboard handling code. Any changes made would mean trade-offs that he's unwilling to make. Nevertheless, it's worth investigating. If this can be reproduced easily and consistently, I can look into it and hopefully find understanding on this issue. So if someone has a list of dummy-proof and very specific instructions to recreate this, I can check it out. This is really important so that I can recreate the problem and verify the fix (assuming there is one). Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
MJW Posted February 22, 2017 Share Posted February 22, 2017 1 hour ago, Rick Brewster said: So if someone has a list of dummy-proof and very specific instructions to recreate this, I can check it out. This is really important so that I can recreate the problem and verify the fix (assuming there is one). There's an image of flowers (from my PaintBucket account) in my comment above. If you use Copy Image to copy the image, then try to import it into PDN using Paste into New Image, you should see the "Not enough memory" error. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted February 28, 2017 Share Posted February 28, 2017 Okay I should have a fix for this in the next update, even if Firefox doesn't fix anything on their side. Paint.NET has a prioritized list of formats that it goes through. If data isn't available in format 1, it will then try format 2, then format 3, etc. However, if any format throws an OutOfMemoryException, the whole process stops and is aborted. The fix is that an OOME won't cause an abort. The format will be retried once after a full garbage collection is forced, and then if it still won't work then the next format will be tried. And it works great with whatever Firefox is doing. 4 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
fjord3 Posted April 6, 2017 Share Posted April 6, 2017 The issue with Firefox is simply the file format of the image. You need to right click the image and select 'View Image' BEFORE copying and pasting. That works for me anyway. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted April 8, 2017 Share Posted April 8, 2017 Well this should work in the 4.0.14 update which should be coming out soon. 1 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.