[Closed] Custom attributes and App data. Memory leak?
Hi!
I created simple eye pupil rig. Eye pupil reacts to open / closed state of the eyelid. When eyelid is closed, or nearly closed, iris starts to open, and when eyelid opens, iris starts to close, until it is in it’s neutral size. (it doesn’t react to light yet…).
Iris size is not directly linked to lid position, since i want to have certain rate of opening / closing of iris. I don’t want blink to create faster iris shape change and so on.
That’s why i stored the “open” into custom attribute, and i read and write this value to / from this location in my script controller script.
Everything works just fine, but if i leave the viewport alone, and let the animation play for 10 minutes or so, 3ds max crashes and says “out of memory”. I’m in max 9.
Seems like writing / reading causes this, since direct “wiring” without storing anything works just fine.
I also tried similar setup with appdata stored to object, and it causes the same crash. Any ideas? It’s not a total disaster, but it would be nice to know if there is a better way to do this.
You can also check the video i made:
Eye pupil animation
code:
theVal = (getAppData $eye_ball 1) as float
(
– Do something to values… then put it back to appData
setAppData $eye_ball 1 (theVal as string)
)
If both Custom Attributes and AppData storage deliver the same problem, I’d suggest that something in the “Do something to values” code block is creating the memory leak. Custom Attributes and AppData storage could not be more different, and the chances of them both having an identical yet independent bug are pretty small.
Perhaps the automatic garbage collection is not being triggered during playback? Try putting something like the following expression in your code:
if heapFree<512000 do gc()
If the crash goes away, then garbage collection would be the problem.
JohnSwafford:
Hmm. Didn’t seem to help. Only thing i have going on, is morpher in eyeball (for iris), morpher in eyelid – both have one morphtarget in first slot, and no stack in objects. Eye lashes are attached to lid with attachment contraint.
Script itself has two variables, and two IFs. I’ll post it if i don’t get it working. Thanks for help!
Post your whole code and we might be better able to help. I have found that forcing values into parameter blocks isn’t a good way to go. You are not really suposed to do it anyways. Maybe a script controller on the track and get the value instead of trying to set the value, if you know what I mean.
I ran into some problems with my car rig where I wanted to store a value over time and I tried using a parameter in a CA def, this caused major slow downs. I finaly just put a local varrialbe inside the CA def and stored the value there and it worked great. I don’t know if this will help what you are doing.
this is the appdata version… Custom attribute version is very similar to this, only difference being lines with get and setAppdata. Just replace those lines with:
“val = eyeBall.pupilSize_CA.pupilSize”
“eyeBall.pupilSize_CA.pupilSize = val”
“lidClose” is a script controller variable for morph target of eye lid.
val = (getAppData $eye_ball 1) as float
(
y = lidClose[1].value
if y >= 30.0 then val += 5.0
if y < 30.0 then val -= 3.0
if val >= 100.0 then val = 100.0
if val <= 0.0 then val = 0.0
setAppData $eye_ball 1 (val as string)
)
val
Might be something very simple, or not. Either way, i don’t have any idea what causes it
I think that you are running into the same problem that I was. Will it work with a local variable in the ca def instead of the app data or parameter?
I’ll try it, and let you know if it makes a difference!
edit OK. I tried it. I still get a crash after 10 minutes or so.
If i got it correcty, i just created a local variable, inside custom attribute definition. I then write and read the value from this variable, instead of from parameter or appData?
Seems like it doesn’t make any difference. It must be something else, i just wonder since it’s very simple test scene, not many objects…
Hmm, I would have to look a lot closer and I just don’t have time at the moment. Sorry.
PEN:
I just ran test for 20 minutes now. I removed the attached eye lashes from eyelid. Now i didn’t get a crash?? Maybe the problem is there. I don’t think there is anything strange going on with eyelashes though.
Some months ago i made a simple script, which projects objects along their z axis to negative direction, and then attaches each projected object to hit surface with attachment constraint. I just thought it would be nice to try the script here… maybe it wasn’t that good idea…
I have to run more tests tomorrow.
I think i’m going to stick with local variable thing anyway. Thanks!