Notifications
Clear all
[Closed] Heap Size
Oct 15, 2013 12:57 am
In my code (maxGC or DotnetGC) does not free local or global array. Where is the problem? collecting buttons in a local variable? How I can collect buttons in array and destroy it later?
rollout HeapSizeRol "HeapSize Rol" width:459 height:395
(
dotNetControl FLP_Buttons "flowLayoutPanel" pos:[2,6] width:454 height:329
button btn_Update "Update" pos:[5,339] width:159 height:50
label lbl_HeapFree "HeapFree:" pos:[170,338] width:285 height:16
label lbl_MaxGC "MaxGC took:" pos:[170,357] width:285 height:16
label lbl_DNGC "DNGC took:" pos:[170,376] width:285 height:16
local MyButtons = #()
fn UpdateButtons =
(
FLP_Buttons.controls.clear()
for i=1 to 100 do
(
b = dotNetObject "Button"
FLP_Buttons.controls.add b
-- dotNet.setLifetimeControl b #dotnet
append MyButtons b
)
)
fn MaxGC =
(
start = timeStamp()
gc light:true
end = timeStamp()
lbl_MaxGC.text = "MaxGC took "+(((end - start) / 1000.0) as string)+" seconds
"
)
fn DNGC =
(
start = timeStamp()
(dotnetClass "System.GC").Collect()
end = timeStamp()
lbl_DNGC.text = "DNGC took "+(((end - start) / 1000.0) as string)+" seconds
"
)
on btn_Update pressed do
(
MaxGC()
DNGC()
UpdateButtons()
lbl_HeapFree.text = "HeapFree:"+(heapfree as string)
)
on HeapSizeRol open do
(
FLP_Buttons.autoScroll = true
)
)
createdialog HeapSizeRol
1 Reply
Oct 15, 2013 12:57 am
Why do you expect it to be collected when you GC before you’ve cleared the references?
on btn_Update pressed do
(
MyButtons = #()
FLP_Buttons.controls.clear()
MaxGC()
DNGC()
UpdateButtons()
lbl_HeapFree.text = "HeapFree:"+(heapfree as string)
)