Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP 9 Collections and memory leaks
Message
From
06/04/2017 05:30:26
 
 
To
05/04/2017 09:00:32
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01649799
Message ID:
01649842
Views:
78
Daniel,

Some points

(1) Even with arrays, it may take a bit of time to release the objects when the array goes out of scope
If you want it quicker, then set the array to null

(2) I've got this code in the destroy of my Dictionary class - based on collection, to clear the contents.
Just in case
*_______________________________________________________________________________
protected function Destroy()
	=m.this.Clear()
	
	try
		unbindevents(m.this)
	catch
	
	endtry
	return dodefault()
endfunc
*_______________________________________________________________________________
function Clear()
	=Collection::Remove(-1)

endfunc
*_______________________________________________________________________________
>Hi you all,
>
>Just a quick question for those of you who have used and abused VFP end-of-life additions, VFP collections.
>
>Up to now, I resisted the urge to use VFP collections. They a bit clumsy as compared to the support for them in say python and a couple of other languages ones. But well I decided to use them for a relatively complex VFP task (with text and xml-via-com parsing).
>
>The good news: it worked and was reasonable simple. The bad one: memory leaks and COM -(and VFP-based) objects lost at runtime.
>
>I first had the initial bad reaction most have in front of mem leaks - nobody like these dangling references ! I then read a nice post by Rick Strahl on his great web site. Once i was back to life... I decided to replace a couple of collections with arrays. It worked wonderfully. The garbage collector would get back to work. Good news:)
>
>I still have numbers of VFP collections in this relatively complex pack of code. A few questions on VFP collection good practices:
>
>1) Would you recommend that I drop them all ? Or can we safely keep them for basic purposes such as collection of integers !
>2) Can you safely add and remove them dynamically with ADDOBJECT and REMOVEOBJECT and expect the garbage to be collected?
>
>Daniel
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform