Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Memory leak when instanciating and releasing cust. class
Message
 
 
To
12/03/2002 15:54:39
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00631753
Message ID:
00631872
Views:
24
I don't see any memory leaks in running your code. However in Test #3 you don't release object created that could create impression of the memory leak.
BTW, you can use < pre > < /pre > tags (no spaces) to preserve code formatting and make the code readable.

>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
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform