View Single Post
Old 29th June 2014, 15:09   #15  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
I'm not sure exactly what M53 was referring to there, I have had a bit of a look for another thread that
resulted in this thread, but could not find it.

But,

Whenever you do something like Subtitle("AveLuma="+String(AverageLuma)) inside ScriptClip, it results in a new string
(the concatenated string, and at every frame, perhaps even 3 strings, the string for "AveLuma=", the String(AverageLuma)
and the concatenated one) that occupies heap memory until Avisynth closes down (I was personally
quite shocked when I discovered that there was no memory garbage collection, not even strings created in script local
functions [I think]).

I'm not alogether sure but think that, if you call scriptclip with ScriptClip("""Subtitle("AveLuma="+String(AverageLuma))""")
then the ScriptClip string arg is instantiated only once, but the SubTitle string arg at every frame.
EDIT: Same with Eval(), strings created at every frame if used inside of Scriptclip, but if you eg
use Grunt()'s 'args' arg, then you can pass in a named argument string variable from outside, and could do an Eval on this
arg string variable that was instantiated only once at main script level.
EDIT: Just had a think about it, ScriptClip does NOT instantiate string mem for its arg at every frame, it is a filter that is linked
into the filter graph, and so the string would only be created when calling the Scriptclip constructor, before frame serving starts.
Inside of ScriptClip, ScriptClip parses the string given to its constructor and at every frame, and every function and filter
is called as if for the first time, all quoted strings inside of Scriptclip are instantiated and on each frame.
If a GScript function is instantiated, eg GSCript(""" Function fn() { Return "Hello"} """) , I dont know if it is in some way tokenized,
and the "Hello" string allocated memory just the once, or every time the function is called.
Perhaps even ScriptClip tokenizes its string arg and so string literals may only be allocated once, perhaps the chosen one will
enlighten us (although he has probably enlightened me on same subject several gazillon times already).



Oh, just found this in developer forum, perhaps of some interest.
http://forum.doom9.org/showthread.php?p=1587841
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

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

Last edited by StainlessS; 29th June 2014 at 16:22.
StainlessS is offline   Reply With Quote