Notifications
Clear all

[Closed] .Net Combobox and gc()

indeed… though as Klaas pointed out… there’s no way to get that invoked whenever max scripts decides to do its garbage collection at random.

Unless I missed a callbacks.addScript #garbagecollection somewhere

And, does the .NET garbage collection collect the same garbage as maxScript gc()? Look at the example. I create an array of max-strings and try to clean it up with .NET garbage collection, but the “heapfree” value does not reset itself. It also doesn’t work with .NET strings (in a max-array).

--maxscript garbage
 --create a bunch of strings to consume some memory
 heapfree--get the amount of free memory
 theMxsArray = #()
 for o = 1 to 50000 do
 (
 	str = o as string
 	append theMxsArray str
 )
 heapfree--get the amount of free memory
 --do .NET garbage collection
 dgc = dotnetclass "system.gc"
 dgc.collect()
 heapfree--get the amount of free memory
 
 
 --.NET garbage
 heapfree--get the amount of free memory
 theDotNetArray = #()
 for o = 1 to 50000 do
 (
 	str = dotNetObject "system.string" (o as string)
 	append theDotNetArray str
 )
 heapfree--get the amount of free memory
 --do .NET garbage collection
 dgc = dotnetclass "system.gc"
 dgc.collect()
 heapfree--get the amount of free memory

Calling the “gc()” works in both cases. So if i understand it right, .NET garbage collection only works in pure .NET cases and cannot replace “gc()”. Am i missing something?

Klaas

Yes, that is how i understand it too, Klaas

Page 2 / 2