Bug 327860 - A lot of memory used after scaling the image multiple times
Summary: A lot of memory used after scaling the image multiple times
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Unclassified
Component: General (show other bugs)
Version: git master (please specify the git hash!)
Platform: Compiled Sources Linux
: HI critical
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-20 12:50 UTC by Juan Palacios
Modified: 2013-11-27 06:10 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Massif output (289.04 KB, text/plain)
2013-11-25 23:14 UTC, Juan Palacios
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Juan Palacios 2013-11-20 12:50:15 UTC
Krita uses a lot of memory when the image size is changed multiple times.

Reproducible: Always

Steps to Reproduce:
1. Create a new image of 400x400 pixels
2. Change the image size to 40x40
3. Change the image size to 400x400
4. Repeat 2 - 3 a few more times
Actual Results:  
Lot of memory in use. In my system, used memory were ~15 GB and still growing.
Also, the resizing process takes longer to complete.

Expected Results:  
Normal memory usage.
Comment 1 Juan Palacios 2013-11-25 23:12:57 UTC
Attached processed valgrind massif tool output while downscaling to 40x40 and scaling to 400x400 an image with original size of 400x400 @8-bit. I repeat this process 2 times. As result, 9GB of memory are consumed.
Comment 2 Juan Palacios 2013-11-25 23:14:18 UTC
Created attachment 83766 [details]
Massif output
Comment 3 Dmitry Kazakov 2013-11-26 06:29:14 UTC
Yeah, it looks something leaks there... :(
Comment 4 Halla Rempt 2013-11-26 13:30:42 UTC
Let's check with memcheck as well.
Comment 5 Halla Rempt 2013-11-26 14:10:39 UTC
What seems to happen is that the layer grows and grows. I just checked using gdb and the boundrect in KisTransformWorker::transforPass is 0, 0, 45807, 4479
Comment 6 Dmitry Kazakov 2013-11-27 06:10:20 UTC
Git commit 7d412c717ad2b9982e9c59699985e54c7070c3fa by Dmitry Kazakov.
Committed on 27/11/2013 at 06:09.
Pushed by dkazakov into branch 'master'.

Fix Transorm Worker to shrink device bounds when doing scale-down

When doing a scale-down a great portion of the image becomes filled
with the default pixel. If the default pixel of a paint device is not
fully transparent, then the exactBounds() will not shrink automatically.
That is why we need to purge() all the default tiles of the paint device
here.

Note: the Crop visitor needs *not* the same stuff, since
      KisPaintDevice::crop() calls KisDataManager::setExtent() which
      explicitly drops all the tiles outside of the requested area.

Special thanks to Boud, who has found the real cause of the bug!

M  +5    -0    krita/image/kis_paint_device.cc
M  +6    -0    krita/image/kis_paint_device.h
M  +6    -0    krita/image/kis_transform_worker.cc
M  +2    -0    krita/image/tiles3/kis_tiled_data_manager.cc

http://commits.kde.org/calligra/7d412c717ad2b9982e9c59699985e54c7070c3fa