Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Memory leak when creating and releasing classes
Message
 
 
To
12/03/2002 10:38:20
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00631512
Message ID:
00631533
Views:
19
Do you've SP5 installed?

>How to solve this?
>Please copy and paste this code and test in VFP6. You will see by your self. I really really need help on this.
>
>*This example is to display a memory leak when creating and releasing classes
>*Save this example code to a PRG named text_form1.prg
>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
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform