Based on just trial and error it seems that layer styles (In this case the stroke) make a simple image use triple the amount of memory in simple seconds.
Created attachment 110955 [details] a project file that uses too much memory when a layer style is applied
Hm, that doesn't really send memory usage up for me, but let's look into it.
Well, most probably, the problem is Windows-specific, because its memory allocator is known to be quite inefficient and fragments memory easily. The real problem is that we use quite inefficient algorithm for calculating "stroke" layers style: instead of using erode/dilate we vectorize the alpha channel and paint a bezier path. This vectorization involves raw memory allocation for selection in KisPixelSelection::outline(), which might cause fragmentation. We have two solutions for this problem: 1) Implement some caching for KisPixelSelection::outline() buffer 2) Implement caching for KisLayerStyleFilterEnvironment::layerOutlineCache(), which was planned, but never implemented (because of point 3) 3) Use more efficient algorithm for the stroke layer style (erode/dilate), which doesn't need all these buffers. Boud, what do you think?
I think we need to do both 1 and 3 -- 1 would also help with other places where the pixel selection outline is used. Though I thought we already had a cache there...
Git commit 2747016a313d98c137eb5d57229e0112854b70aa by Dmitry Kazakov. Committed on 09/06/2018 at 07:07. Pushed by dkazakov into branch 'master'. Connect Erode/Dilate algorithms to "Stroke" layer style Now it is **much** faster, more roundish and doesn't eat your memory :) Related: bug 361130 CC:kimageshop@kde.org M +0 -18 libs/image/layerstyles/kis_layer_style_filter_environment.cpp M +0 -2 libs/image/layerstyles/kis_layer_style_filter_environment.h M +43 -46 libs/image/layerstyles/kis_ls_stroke_filter.cpp https://commits.kde.org/krita/2747016a313d98c137eb5d57229e0112854b70aa
Git commit ace6d8252a5a7b783ace53added6584f315ebe1f by Dmitry Kazakov. Committed on 09/06/2018 at 09:00. Pushed by dkazakov into branch 'krita/4.0'. Connect Erode/Dilate algorithms to "Stroke" layer style Now it is **much** faster, more roundish and doesn't eat your memory :) Related: bug 361130 CC:kimageshop@kde.org M +0 -18 libs/image/layerstyles/kis_layer_style_filter_environment.cpp M +0 -2 libs/image/layerstyles/kis_layer_style_filter_environment.h M +43 -46 libs/image/layerstyles/kis_ls_stroke_filter.cpp https://commits.kde.org/krita/ace6d8252a5a7b783ace53added6584f315ebe1f
Git commit af21ce68e13621dd6a84fd64a767b68e69ec5d2f by Andrey Kamakin, on behalf of Dmitry Kazakov. Committed on 26/06/2018 at 14:18. Pushed by akamakin into branch 'akamakin/T8628-multithreading-optimization'. Connect Erode/Dilate algorithms to "Stroke" layer style Now it is **much** faster, more roundish and doesn't eat your memory :) Related: bug 361130 CC:kimageshop@kde.org M +0 -18 libs/image/layerstyles/kis_layer_style_filter_environment.cpp M +0 -2 libs/image/layerstyles/kis_layer_style_filter_environment.h M +43 -46 libs/image/layerstyles/kis_ls_stroke_filter.cpp https://commits.kde.org/krita/af21ce68e13621dd6a84fd64a767b68e69ec5d2f