Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 19th December 2016, 12:23   #1  |  Link
may24
Registered User
 
Join Date: Jan 2008
Posts: 41
Avisynth Memory allocation

Hi all,

can someone share me a few insights on how Avisynth (not the plus version) handles memory allocation.

For instance: If I write a .avs script hat opens two 1080p video files (AVC) and each one gets its own variable, I suspect avisynth will allocate memory for both making it accessible via the variables.
Also I assume that this references will be available due script has finished execution.
Or is there kind of an "deconstructor" to explicitly free memory ?

Now, what if I re-assign an new Video file to the same variable ? Will the "old" allocation be dropped and a new be made ?

I've read that Plugins (such as external decoders: ffmpeg-source, lsmash ect) do their own memory management.

So in the end it seems quite impossible to guess how much memory your script will allocate until you open it and check with a task manager ... and even that seems to be fairly correct as tailing functions, scripts or plugins will add to this number making it quite unpredictable (think of de-interlacers).

Or do I miss anything here ?
Can you give me an insight on how avs memory management works
may24 is offline   Reply With Quote
Old 19th December 2016, 12:31   #2  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Los Angeles, California
Posts: 2,058
However it works, does it matter??
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is offline   Reply With Quote
Old 19th December 2016, 13:12   #3  |  Link
amayra
Quality Checker
 
amayra's Avatar
 
Join Date: Aug 2013
Posts: 174
this will take more time than you think if you cant understanding source code of Avisynth so... I suggest you to try AVSMeter to know how much memory your script will allocate
__________________
I love Doom9
amayra is offline   Reply With Quote
Old 19th December 2016, 19:16   #4  |  Link
davidhorman
I'm the Doctor
 
Join Date: Jan 2004
Posts: 1,327
Quote:
Now, what if I re-assign an new Video file to the same variable ? Will the "old" allocation be dropped and a new be made ?
If you had a script like this:

Code:
a=avisource("one.avi")
b=avisource("two.avi")

c=a+b

b=avisource("three.avi")

return b+c
AviSynth is not going to be able to drop any "allocation" for the first use of b, because that object is still going to be required whenever a frame is fetched.
__________________
My AviSynth filters / I'm the Doctor
davidhorman is offline   Reply With Quote
Old 19th December 2016, 20:47   #5  |  Link
may24
Registered User
 
Join Date: Jan 2008
Posts: 41
Thanks a lot for your answers.

Now, what about this
Code:
a=avisource("one.avi")
b=avisource("two.avi")

return(a)
Will Avisynth recognize that instance "b" is never used and therefore de-allocate the memory ?
may24 is offline   Reply With Quote
Old 19th December 2016, 21:13   #6  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 5,093
Quote:
Originally Posted by may24 View Post
Now, what about this
Code:
a=avisource("one.avi")
b=avisource("two.avi")

return(a)
Will Avisynth recognize that instance "b" is never used and therefore de-allocate the memory ?
Dont know but
Code:
a=avisource("one.avi")
b=avisource("two.avi")
b=0 # would for sure call destructor on clip b
return(a)
It probably does not matter much either way.

EDIT: Unless eg
Code:
a=avisource("one.avi")
b=avisource("two.avi")
c=b
b=0 # Instance c copy of b may well still persist and so "two.avi may remain open.
return(a)
On second thoughts, methinks maybe local variables at main script level (without Global specifier) will still persist
during frame serving, but local variables at local function level would cease to be (unless called via some runtime environment filter
eg Scriptclip). I guess the definitive answer is 'it depends'.

Here post on order that things occur during compile stage, might be of interest:- http://forum.doom9.org/showthread.ph...54#post1594454

EDIT: You could always find out for yourself (check out RT_Stats)

Code:
#a=avisource("one.avi")
#b=avisource("two.avi")

a=ColorBars.KillAudio
b=ColorBars.KillAudio

SSS="""
    n=current_frame
    Ex=RT_VarExist("b")
    RT_DebugF("%d] b %s Exist",n,Ex?"does":"does not",name="TEST: ")
    RT_Subtitle("%d] b %s Exist",n,Ex?"does":"does not")
"""

return a.ScriptClip(SSS)
During Frameserving from DebugView (google)
Code:
00000005	21:11:11.515	TEST: 0] b does Exist
00000006	21:11:11.562	TEST: 1] b does Exist	
00000007	21:11:11.593	TEST: 2] b does Exist	
00000008	21:11:11.625	TEST: 3] b does Exist	
00000009	21:11:11.656	TEST: 4] b does Exist	
00000010	21:11:11.687	TEST: 5] b does Exist
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but are any of them infinitely bigger ???

Last edited by StainlessS; 19th December 2016 at 22:25.
StainlessS is online now   Reply With Quote
Old 19th December 2016, 22:21   #7  |  Link
Groucho2004
 
Join Date: Mar 2006
Posts: 3,494
Quote:
Originally Posted by may24 View Post
Now, what if I re-assign an new Video file to the same variable ? Will the "old" allocation be dropped and a new be made ?
Yes.

Quote:
Originally Posted by may24 View Post
Now, what about this
Code:
a=avisource("one.avi")
b=avisource("two.avi")

return(a)
Will Avisynth recognize that instance "b" is never used and therefore de-allocate the memory ?
No.

It took 2 minutes to test that with AVSMeter as suggested above.

Last edited by Groucho2004; 19th December 2016 at 22:27.
Groucho2004 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 14:34.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2017, vBulletin Solutions Inc.