Bug 449547

Summary: Suspected memory leak
Product: [Applications] krita Reporter: thetwo <thetwo222>
Component: Tile managerAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: dimula73, halla, tamtamy.tymona
Priority: NOR    
Version First Reported In: 5.0.2   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description thetwo 2022-02-03 09:19:08 UTC
Provided by users of the krita Chinese community, the kra file has been uploaded.
There are only 4 layers in total, but it occupies 19GiB, and it prompts that the memory is insufficient.
Doing anything (Cut, Merge, Hide, Export) to the topmost "颜料图层 2" will cause krita to get stuck
I have already verified on my computer
Comment 1 thetwo 2022-02-03 09:21:46 UTC
File uploads have a 4000kb limit
Please download the kra file here: https://ufile.io/3gbpo7hc
Comment 2 Dmitry Kazakov 2022-02-03 14:13:57 UTC
I can confirm the bug. I don't think Krita actually occupies this chunk of memory, it is just an issue in a way how the image size is calculated :)
Comment 3 Dmitry Kazakov 2022-02-03 14:20:19 UTC
Hi, thetwo!

The problem is that "layer 2" has some dot at are near position 57216x88192. Which makes the layer extremely huge. To quickly workaround this issue you can just click on Image->Trim to Image Size. It will resolve the issue completely.

Now the main question is how did manage to get pixel data at such distant area? Did you use any perspective transform on this layer?
Comment 4 thetwo 2022-02-04 04:23:12 UTC
(In reply to Dmitry Kazakov from comment #3)
> Hi, thetwo!
> 
> The problem is that "layer 2" has some dot at are near position 57216x88192.
> Which makes the layer extremely huge. To quickly workaround this issue you
> can just click on Image->Trim to Image Size. It will resolve the issue
> completely.
> 
> Now the main question is how did manage to get pixel data at such distant
> area? Did you use any perspective transform on this layer?

I asked the client, and he said he didn't use any shapeshifting tools or anything. During interrogation later, he said that his use of the tablet often resulted in false touches, possibly leaving data far away from the canvas under such circumstances.
This sounds possible, I made a 40GiB document like this, but it's just slow and doesn't cause krita to crash
Comment 5 Tiar 2022-02-04 15:25:44 UTC
I wonder if it would be possible to add the "Trim to Canvas on exiting Krita" feature but with some margin around the edges? I'm not really an artist all that much, but in my case, I don't want to use that option in the current form because I do want to have some area around the canvas remembered (it's useful when you change composition or move objects etc.). On the other hand, I probably wouldn't care much in most cases if Krita cut off areas around the canvas that are further away than let's say the bigger dimension of the painting (for example if you have painting 2000x3000, then the remembered area would be max 8000x9000). That would be often enough for a sanity check. (Though should still be optional).

Not sure if relevant but I've heard of people for whom waiting time for the canvas to get the focus on hover is too long, so they click on the canvas, it might be that some people click outside of the canvas without realizing it does leave a mark. Maybe it would be good to ensure that if the canvas was not in focus before the click, the click shouldn't leave a brush mark?
Comment 6 thetwo 2022-02-04 15:44:10 UTC
(In reply to Tiar from comment #5)
> I wonder if it would be possible to add the "Trim to Canvas on exiting
> Krita" feature but with some margin around the edges? I'm not really an
> artist all that much, but in my case, I don't want to use that option in the
> current form because I do want to have some area around the canvas
> remembered (it's useful when you change composition or move objects etc.).
> On the other hand, I probably wouldn't care much in most cases if Krita cut
> off areas around the canvas that are further away than let's say the bigger
> dimension of the painting (for example if you have painting 2000x3000, then
> the remembered area would be max 8000x9000). That would be often enough for
> a sanity check. (Though should still be optional).
> 
> Not sure if relevant but I've heard of people for whom waiting time for the
> canvas to get the focus on hover is too long, so they click on the canvas,
> it might be that some people click outside of the canvas without realizing
> it does leave a mark. Maybe it would be good to ensure that if the canvas
> was not in focus before the click, the click shouldn't leave a brush mark?

For me personally, it's better to define an area when painting, not just when exiting. For example, "x-axis - retention area; y-axis retention area". This is to protect some images from being cropped around the edges of the image. And further afield, I hope to be directly unable to paint.
Comment 7 Halla Rempt 2022-08-09 12:04:10 UTC
I think it's sufficient that we now have Trim Files Before Saving.