View Full Version : Script caused Fatal Error, what am I doing wrong?

01 January 2009, 11:39 PM
I was working on a script yesterday and got an error that said something about an error occuring during garbage collection... I kept working and a couple minutes later, Max crashed completely. When I tried to reopen it, the loading screen came up and then:


and it wouldn't open at all! Luckily a restart on my computer fixed the error (for now), but I am fairly new to scripting and have no idea what caused this in the first place and I would like to avoid further problems. Can anyone help me? I was working with creating a bitmap with the RenderMap function and then reading the RGB values per polygon, could this be the source of my problems? I do not know what the program is doing with the bitmap after creation, do I have to specify a folder for it to be saved in? Any help as to what garbage collection means or DBX CAS 0 or anything like that would be much apprectiated. Thank you.

01 January 2009, 11:28 AM

Garbage collection is used for cleaning up memory (RAM) that Max uses internally.
a maxscript function: gc() is used just for that
Working with bitmaps is known for beeing a memory eater.
so use gc and/or freesceneBitmaps fns
There is a topic on that issue ine the Maxscript help.

02 February 2009, 11:25 PM
Thanks for replying, ZBuffer

When the problem occurred, I tried using gc() in the listener, and it gave me the same message about an error occurring during garbage collection. Shortly after this is when Max crashed and gave me the fatal error and would not re-open. Also, I do not want to put gc() in the script itself because I want to be able to keep the undo history.

I didn't know about freesceneBitmaps() but I'm not sure if this will help as I am only dealing with 2 bitmaps at a time and there aren't any others in the scene. But maybe my script is making lots of copies of the same bitmaps? I will try putting the freesceneBitmaps() line in my script, just before the bitmaps are created and see if this helps.

The error does not occur every time, so pinning it down to one cause is tricky for me and I'm sorry I cannot be more specific about when it happens (because I just don't know). The Fatal Error was scary though, I saw on some CAD forums that brand new RAM was needed, or clean install of Windows was needed, etc - so I really want to avoid triggering this error again.

02 February 2009, 03:22 PM
gc light:true

should allow you to call the garbage collector without flushing the undo history if that helps.

02 February 2009, 07:49 PM
thanks LoneRobot, I will try adding that to my script and see if I am still getting errors

CGTalk Moderation
02 February 2009, 07:49 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.