Notifications
Clear all

[Closed] Free memory with dotnet drawing bitmap

Thanks for help

I have another question about How to Free memory with dotnet drawing bitmap

when after drawing many pictures with dotnet , that will show me
runtime error: dotNet runtime exception
about memory not enough

does anyone know how to free the dotnet using memory ?

I have tried “freesceneBitmap()” but not work

(
local bmpDisplayed = dotNetObject “System.Drawing.Bitmap” “c: est.dds”
local bmpRectangle = dotNetObject “System.Drawing.Rectangle” 0 0 512 512

rollout uiDotNetPictureBox “.NET PictureBox” width:512 height:512
(
dotNetControl uiPictureBox “System.Windows.Forms.PictureBox” pos:[0,0] width:320 height:240

on uiPictureBox Paint senderArg paintEventArgs do
(
Graphics = paintEventArgs.Graphics
Graphics.DrawImage bmpDisplayed bmpRectangle
)
)

try(destroyDialog uiDotNetPictureBox) catch()
createdialog uiDotNetPictureBox style:#(#style_titlebar, #style_border, #style_sysmenu)
)

3 Replies

Hey David, have you tried this?

dgc = dotnetclass "system.gc"
dgc.collect()

hello art ,I have no idea how to use the code
I’ve try run the code , but it show me “undefined”
and seems like did not free the memory

I’m Noob with maxscript and dotnet

[left]dgc = dotnetclass “system.gc”

dgc.collect()

[/left]

[left]Thank you ![/left]

That’s it, anyway I was having the same problem with pictureboxes that’s why I’ve wrote a kustom class either way it eats alot of memory, one thing I’ve noticed is that when you minimize max and restore it again, it solves the issue