#DEFINE NUM_ITERATIONS 10 #DEFINE CR CHR(13) _screen.Cls() LOCAL loForm, ; ii, ; lnStartMem, ; lnStopMem loForm = CREATEOBJECT("cTestForm") loForm.Release() loForm = .NULL. *------------------------------------------------------------------------ *-- No memory leak *------------------------------------------------------------------------ lnStartMem = VAL(SYS(1016)) FOR ii = 1 TO NUM_ITERATIONS loForm = CREATEOBJECT("cTestForm") loForm.Release() loForm = .NULL. ENDFOR lnStopMem = VAL(SYS(1016)) =ShowMemUsage("No Leak", lnStartMem, lnStopMem) *------------------------------------------------------------------------ *------------------------------------------------------------------------ *-- Memory leak *------------------------------------------------------------------------ lnStartMem = VAL(SYS(1016)) FOR ii = 1 TO NUM_ITERATIONS loForm = CREATEOBJECT("cTestForm") loForm.LeakMemory() loForm.Release() loForm = .NULL. ENDFOR lnStopMem = VAL(SYS(1016)) =ShowMemUsage("Memory Leak", lnStartMem, lnStopMem) *------------------------------------------------------------------------ RETURN PROCEDURE ShowMemUsage(tcHeading, tnStartMem, tnStopMem) WITH _screen .Print(REPLICATE("-", 120) + CR) .Print(tcHeading + CR) .Print(REPLICATE("-", 120) + CR) .Print("Starting: " + TRANSFORM(tnStartMem, "@R 999,999,999,999") + CR) .Print("Ending: " + TRANSFORM(tnStopMem, "@R 999,999,999,999") + CR) .Print("Difference: " + TRANSFORM(tnStopMem - tnStartMem, "@R 999,999,999,999") + CR) .Print(REPLICATE("-", 120) + CR) .Print(CR) ENDWITH ENDPROC ************************************************** *-- Class: ctestform DEFINE CLASS cTestForm AS form Top = 0 Left = 0 Height = 95 Width = 507 DoCreate = .T. Caption = "SetAll Method - Memory Leak" Name = "cTestForm" ADD OBJECT text1 AS textbox WITH ; Height = 23, ; Left = 24, ; Top = 24, ; Width = 48, ; Name = "Text1" ADD OBJECT text2 AS textbox WITH ; Height = 23, ; Left = 84, ; Top = 24, ; Width = 48, ; Name = "Text2" ADD OBJECT text3 AS textbox WITH ; Height = 23, ; Left = 144, ; Top = 24, ; Width = 48, ; Name = "Text3" ADD OBJECT text4 AS textbox WITH ; Height = 23, ; Left = 204, ; Top = 24, ; Width = 48, ; Name = "Text4" ADD OBJECT text5 AS textbox WITH ; Height = 23, ; Left = 264, ; Top = 24, ; Width = 48, ; Name = "Text5" ADD OBJECT text6 AS textbox WITH ; Height = 23, ; Left = 324, ; Top = 24, ; Width = 48, ; Name = "Text6" ADD OBJECT text7 AS textbox WITH ; Height = 23, ; Left = 384, ; Top = 24, ; Width = 48, ; Name = "Text7" ADD OBJECT text8 AS textbox WITH ; Height = 23, ; Left = 444, ; Top = 24, ; Width = 48, ; Name = "Text8" ADD OBJECT combo1 AS combobox WITH ; Height = 24, ; Left = 24, ; Top = 60, ; Width = 48, ; Name = "Combo1" ADD OBJECT combo2 AS combobox WITH ; Height = 24, ; Left = 84, ; Top = 60, ; Width = 48, ; Name = "Combo2" ADD OBJECT combo3 AS combobox WITH ; Height = 24, ; Left = 144, ; Top = 60, ; Width = 48, ; Name = "Combo3" ADD OBJECT combo4 AS combobox WITH ; Height = 24, ; Left = 204, ; Top = 60, ; Width = 48, ; Name = "Combo4" ADD OBJECT combo5 AS combobox WITH ; Height = 24, ; Left = 264, ; Top = 60, ; Width = 48, ; Name = "Combo5" ADD OBJECT combo6 AS combobox WITH ; Height = 24, ; Left = 324, ; Top = 60, ; Width = 48, ; Name = "Combo6" ADD OBJECT combo7 AS combobox WITH ; Height = 24, ; Left = 384, ; Top = 60, ; Width = 48, ; Name = "Combo7" ADD OBJECT combo8 AS combobox WITH ; Height = 24, ; Left = 444, ; Top = 60, ; Width = 48, ; Name = "Combo8" PROCEDURE LeakMemory() ******************************************************************************** *-- Using SetAll to assign a Character Value seems to cause a leak ******************************************************************************** this.SetAll("Tag", "Where is all the memory going?") &&this.SetAll("Format", "RL") &&this.SetAll("InputMask", "999,999,999,999,999") ******************************************************************************** ******************************************************************************** *-- Using SetAll to assign a Non-Character Value DOES NOT seem to cause a leak ******************************************************************************** &&this.SetAll("ForeColor", RGB(255,0,0)) &&this.SetAll("Left", 100) &&this.SetAll("FontBold", .T.) ******************************************************************************** ENDPROC ENDDEFINE>Is there any tool out there that can detect memory leaks in VFP?