Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Memory leak when instanciating and releasing cust. class
Message
De
12/03/2002 15:54:39
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Titre:
Memory leak when instanciating and releasing cust. class
Divers
Thread ID:
00631753
Message ID:
00631753
Vues:
50
Please help. Copy and paste the following code as a prg in VFP6 or 7. You will find out the memory is going up every new class even when the object was released.

oMainForm = NEWOBJECT("testform","text_form1.prg")
oMainForm.visible=.t.
READ EVENTS
define class testform as form
oObject = .NULL.
PROCEDURE Remove_Form
lparameter olForm
thisform.oObject = .NULL.
ENDPROC
ADD OBJECT command1 as commandbutton with ;
left = 60, top = 20, height = 40, width = 200,;
caption = "Current Memory"
PROCEDURE command1.click
messagebox(sys(1016))
ENDPROC
ADD OBJECT command2 as commandbutton with ;
left = 60, top = 60, height = 40, width = 200,;
caption ="Run Test #1 (no custom classes)"
PROCEDURE command2.click
messagebox(sys(1016)) && Memory used before creation
thisform.oObject = newobject("form")
thisform.oObject.visible = .t.
messagebox(sys(1016)) && Memory used after creation
thisform.oObject.release()
messagebox(sys(1016)) && Memory used after release
ENDPROC
ADD OBJECT command3 as commandbutton with ;
left = 60, top = 100, height = 40, width = 200,;
caption ="Run Test #2 (using a custom form)"
PROCEDURE command3.click
messagebox(sys(1016)) && Memory used before creation
thisform.oObject = newobject("testform2","text_form1.prg")
thisform.oObject.visible = .t.
messagebox(sys(1016)) && Memory used after creation
thisform.oObject.release()
messagebox(sys(1016)) && Memory used after release
ENDPROC
ADD OBJECT command4 as commandbutton with ;
left = 60, top = 140, height = 40, width = 200,;
caption ="Run Test #3 (using a custom form)"
PROCEDURE command4.click
messagebox(sys(1016)) && Memory used before creation
thisform.oObject = newobject("testform3","text_form1.prg",NULL,thisform)
thisform.oObject.visible = .t.
messagebox(sys(1016)) && Memory used after creation
ENDPROC
PROCEDURE Destroy
CLEAR EVENTS
ENDPROC
enddefine
define class test_txtbox as textbox
height = 15
enddefine
define class testform2 as form
ADD OBJECT textbox1 as test_txtbox with ;
left = 100, top = 100
enddefine
define class testform3 as form
ReturnTo = .NULL.
PROCEDURE INIT
lparameter oForm
thisform.ReturnTo = oForm
ENDPROC
ADD OBJECT command1 as commandbutton with ;
left = 100, top = 100
PROCEDURE command1.click
thisform.ReturnTo.remove_form(thisform)
thisform.ReturnTo = .NULL.
thisform.release()
ENDPROC
enddefine
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform