AviSynth / AviSynthPlus

AviSynth with improvements
http://avs-plus.net
975 stars 75 forks source link

Memory leak with ScriptClip? #340

Closed Dogway closed 1 year ago

Dogway commented 1 year ago

Runing several ScriptClip with propSet() calls inside them, causes a constant raising of RAM. This is worse the more inter-filtering you are performing between the ScriptClips:

ex_smooth() # or any other filter
a=last
ScriptClip(function[a]() {
propSet("_DurationDen",propGetInt(a,"_DurationDen")*2)
propSet("_DurationNum",propGetInt(a,"_DurationNum")  )
} )
a=ex_smooth()
ScriptClip(function[a]() {
propSet("_DurationDen",propGetInt(a,"_DurationDen")*2)
propSet("_DurationNum",propGetInt(a,"_DurationNum")  )
} )
a=ex_smooth()
ScriptClip(function[a]() {
propSet("_DurationDen",propGetInt(a,"_DurationDen")*2)
propSet("_DurationNum",propGetInt(a,"_DurationNum")  )
} )
a=ex_smooth()
ScriptClip(function[a]() {
propSet("_DurationDen",propGetInt(a,"_DurationDen")*2)
propSet("_DurationNum",propGetInt(a,"_DurationNum")  )
} )

When the ScriptClips are commented and only the 4 filters are kept the RAM is steady.

pinterf commented 1 year ago

Thanks for the report. It won't be easy, I think. If there is initially a frame property defined and there is a runtime function inside ScriptClip, then it leaks. Totally weird.

Colorbars(staticframes=false, pixel_type="YV12")
propSet("anything",30) # Line#1
ScriptClip(function[]() {
x = 1.0
x = AverageLuma(last) # Line#2
Blur(x/255.0)
} )
# leak: if both #1 AND #2 exists
Dogway commented 1 year ago

Nice you could narrow it down. No problem, just wanted to let you know, I added some knobs inside QTGMC+ to skip runtime frameprop assignment and fixed my issues.

In any case your example is more worrying as it's a more generic case. Like for example set "_FieldBased" to 0 after TIVTC and later in the script chain any kind of ScriptClip call...

pinterf commented 1 year ago

Status report: problem found and seems to be fixed, I hope I can clean it up this week.