Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Looking for memory leak detection software for VFP
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00367283
Message ID:
00367466
Vues:
18
I recently ran into what I believe is a nasty memory leak. We too are using VFP 6.0 SP3. The bug appears to be related with the SetAll() method when it is used to set a charcter type property. We have an application in which the main TX screen intstantiates and the releases several different lookup forms to complete a single TX. We had alot of users getting GPF's late in the afternoon after they had completed around the same no. of TX's. After some very painful testing and investigating, I believe I narrowed the memory leak down to the SetAll() method. I have been unable to find any references to this problem, but hope to confirm this with MS tech support sometime this week. Below is some sample code to reproduce what I think is the leak.

Please let me know if anyone has any thoughts on this.
#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?
>
>I am using VFP6 SP3 which I know fixes several memory leaks. I still have the memory leaks.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform