Size, Position and Rotate - doesn't release memory when scaling?

What is your operating system?
Linux

What is your Shotcut version (see Help > About Shotcut)? Is it 32-bit?
22.01.30 and 22.06.23 (checked on both)

Can you repeat the problem? If so, what are the steps?
(Please be specific and use the names as seen in Shotcut, preferably English. Include a screenshot or screen recording if you can. Also, you can attach logs from either View > Application Log or right-click a job and choose View Log.)

Repeatable. Problem occurs when doing export h264_vaapi (but codec probably doesn’t matter here). (deinterlaces: yadif - temporal + spatial (best), interpolation: lanczos (best)).

I have jpg file which is quite big 6240x3512 piksels around 15MB. I put Size, Position and Rotate filter on it with scale 102 at the beginning (point 0 sec) and at the end with scale 179.9 (point 24 sec). (fill/center/middle). Such scaling causes terrible memory usage increase when exporting. From around 6GB at the begging to 32 GB somewhere at the middle and that causes job export crash (with incorrect message

[producer_xml] parse fatal: Extra content at the end of the document
row: 11438 col: 1

However definitely it’s not caused with xml as when turning off Size, Position and Rotate filter everything works ok. Export is successfull then.

It looks that when doing scalling (upscalling), memory is not released after every frame (but probably at the end of filter).

When editing everything is ok.

I do not reproduce excessive memory usage when trying to create a simple project using this file and the Size/Position/Rotate filter. But maybe there is an interaction among multiple filters.

Can you make a bare minimum example project that uses the file I linked?

Maybe something about your filter is causing this error? Or maybe this message is unrelated.

Hi,

It might be related with some filters “package”. Please take this small mini project which is causing this problem after around 55 percent of rendering (when having 32GB of RAM).

The zip file is quite big, 27 MB, due to big jpg inside.

I’ve also added screenshoots from memory monitor and export settings.

When the export is “killed”, then the system tries to run it again in non-parallel mode. Here I didn’t continue this and stopped the job manually but from my previous experiences, the same thing happens also in non-parallel mode.

Hope this helps.

Additional appendix. I made one attempt more but this time I divided this clip into smaller (adding some additional keyframes inbetween). Looking on memory monitor I have serious doubts if memory is fully released after finishing processing one clip. It looks like that only part of memory is released and the rest is still kept. Finally this second project also crashes due to insufficient memory. Very strange.

In the second zip file, you have second version of the project (without jpg file as it’s the same as in the first one), and additional memory monitor screenshoot - memory usage looks like stairs, which means that memory is released only in small percentage after one clip rendering. It looks like serious memory leaking problem.

Thank you for the test project files. I am able to reproduce the memory leak problem using your project on Windows.

After some experiments, I find that I can reduce the project by removing all but the Corners and SPR filters:
image
If I remove either of those, the problem does not occur. So there must be some interaction between the two filters. This is an important clue.

Hopefully this report is related to this other report that I was never able to solve:

That problem is also related to the SPR filter.

Hmmm… that’s not good that it’s not possible to solve this problem (or at least not easy) as it might discourage many people from using shotcut in a bit bigger projects (mine is currently 5 min and I don’t have enough memory).

I’m wondering if it’s the problem of these two filters being together, of some more general problem of mechanism creating a new frame and executing filter by filter? As the error can be either in one of those two filters or in this general mechanism being one step above (coordinator). In the second case it might happen that some other filters being together cause memory leaking. It might be more visible in case of those two filters as they use big amount of data but in practice it might concern more filters?

What comes to my mind, but please treat this as very general ideas as definitely I’m not expert here, in particular not in shotcut “programming construction”, it looks like that additional copy of frames or jpg source files are created and not being released. Do you use copy constructors somewhere? Sometimes they are used to transfer big memory areas between objects but if it’s in incorrect way, it happens that instead of one expected copy, we have two and one is some kind of orphan.

When playing with different filters I also noticed some time ago, but here I’m not fully sure, that is looks like that most of them works on the output from the previous filter (if we have many in array, which is of course expected) but I found one or two which seemed to work on input image (the image “send” to the first filter) and not on the output of the previous filter. However I didn’t report this and now I don’t remember details.

I will try to make more “playing” with this problem and if I find sth interesting which could suggest the reason more in details, I will let you know.

Edit: I executed some additional tests to check if changing any parameters within these two filters will have impact on this memory leaking. I expected that no, but just in case I checked it and it confirmed my expectations. Additionally adding any additional filters before these two, or removing alpha channel after corner pin and before size, position and rotate doesn’t help.

In case of Corner Pin, I did: 1) changed position of corners 2) changed interpolator 2) changed alpha operation (sure not all possible values but some).

In case of Size, Position & Rotate, I did: 1) changed size mode from fill to fit 2) changed background colour to black instead of transparent.

Additionally in editing more, I unmarked Realtime (frame dropping) option and hit Play. Then also it caused significant memory leaking.

I also made one experiment more: two times the same corner pin filter (and no size… at all) either two times the same size, position and rotate (and no corner pin). It seems that this problem doesn’t occur then (or in very small almost invisible way as I didn’t use any professional memory profiler, just simple tool).

Probably it will not help too much, but just in case…

Ok more info. I found one other filters mix causing the similar significant memory increase usage (=leaking).

When having only two filters: Mask:Simple Shape and Size, Position & Rotate we have exactly the same story.

shotcut_resize_problem3.zip - Google Drive (jpg file as in the first project)

I’m wondering if it might be somehow related with transparency layer (as both Corner pin and Mask: Simple Shape and Size “introduce” this).

This is fixed for the next version (and nightly build).

3 Likes

Wow! Great! :slight_smile: :slight_smile: :slight_smile:

Could you shortly say what was the reason?

See this comment for the reason

1 Like

I’m sorry for bothering you. Do you know (at least approx.) when new shotcut version with this error fixed will be released?

Middle of December

1 Like