Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Object destruction
Message
From
04/02/2014 13:45:04
 
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 8
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Web
Miscellaneous
Thread ID:
01592795
Message ID:
01593172
Views:
41
>>You might try out by analogy (as you ARE in the playing stage ;-) ) practice to define and distinguish between strong and weak object references
>What do you mean with strong versus weak object reference?

Sorry Peter, that one you have to stackoverflow yourself. Me writing about it would take too long: Keywords strong/Weak References, iOS and ARD and to a lesser degree Java, Garbage Collection, Strong, Soft,Weak Reference. Also http://sealedabstract.com/rants/why-mobile-web-apps-are-slow/ and google some of posts about that one, if you don't want to read up on GC strategies in Java, Dotnet, Python, [iOS]...

After you have read up part of it, the following code will be much clearer, esp as you mentioned adding further references (typical for "weak" like usually .parent) - I had guessed the effect of backward destruction to be better, but knew that vfp the addproperty way would be much faster. CONTROL class does not sport add/new/removeobject, so might be interesting middle path for GUI objects. A scientific approach would also time 10K objects layed ot [1*10000, 10*1000, 100*100, 1000*10] - you can post the reworked code back ;-)
I know controlling your own garbage is usually a no-no, but as you manually control .RemoveObject() IAC, sometimes going AddProperty/Store might give you more speed where it might fit - in full screen modal perhaps more useful than in normal GUI.
clea
LOCAL lcTestList
lcTestList = "timPureAddP,timRizeAddP,timDownAddP,timPureAddO,timRizeAddO,timDownAddO, DestroyOverhead"
FOR lnRun = 1 TO ALINES(laTest, lcTestList,5,",")
	loX = CREATEOBJECT(laTest[m.lnRun])
	loX.Doit()
next

DEFINE CLASS destroyoverhead as container
	nThousands = 1
	nControlCount = 1000
	nObjRun = 0
	nSec1 = 0
	nSec2 = 0
	nSec3 = 0
	cObjList = "Line,TextBox,Container,Custom"
	cObjPrefix = "oStro"
	cObjType = "Empty"
	lStackDown = .f.
	oCont = .null.
	
	FUNCTION DoIt
		LOCAL lcObj, lnObj, lnRun
		FOR lnRun = 5 TO 5 STEP 40
			FOR lnObj = 1 TO ALINES(laObj,this.cObjList,5, ",")
				= SYS(1104)
				this.oCont = CREATEOBJECT("Container")
				*this.oCont = CREATEOBJECT("Custom")
				this.DoOne(laObj[m.lnObj], m.lnRun)
				this.oCont = .null.
				this.nSec3 = seconds()
				= SYS(1104)
				= this.ShowTime()
			next
		next

	
	FUNCTION DoOne(tcObjType, tnThousands)
		this.cObjType = EVL(m.tcObjType, this.cObjType)
		this.nThousands = EVL(m.tnThousands, this.nThousands)
		this.nControlCount = this.nThousands*1000
		this.nSec1 = seconds()
		= this.Build()
		this.nSec2 = seconds()
		*SET STEP ON	
		IF this.lStackDown
			= this.TearRize()
		ELSE
			= this.TearDown()
		ENDIF
		RETURN
		
	FUNCTION ShowTime(tcWhat)
		LOCAL lcLog
		lcLog = TRANSFORM(DATETIME());
			+ " " + PADL(ALLTRIM(STR((this.nSec2-this.nSec1)*1000)),9,"0");
			+ " " + PADL(ALLTRIM(STR((this.nSec3-this.nSec2)*1000)),9,"0");
			+ STR(this.nControlCount, 9) ;
			+ " " + PADR(this.Class,15)  +  this.cObjType
		? m.lcLog 
		
	FUNCTION Build()
		for this.nObjRun  = 1 TO this.nControlCount
			llOk = this.Adder()
			ASSERT llOk
		next
		RETURN
	FUNCTION CurProp()
		return this.cObjPrefix + PADL(ALLTRIM(STR(this.nObjRun)),5,"0")
		
	FUNCTION TearRize()
		for this.nObjRun   = 1 TO this.nControlCount
			= this.Remover()
		next
		RETURN

	FUNCTION TearDown()
		for this.nObjRun   = this.nControlCount TO 1 STEP -1
			= this.Remover()
		next

	FUNCTION Adder()
		RETURN !EMPTY(this.CurProp()) 

	FUNCTION Remover()
		RETURN !EMPTY(this.CurProp()) 
	
ENDDEFINE

DEFINE CLASS timPureAddO as destroyoverhead		
	FUNCTION Adder()
		RETURN this.oCont.AddObject(this.CurProp(), this.cObjType)

ENDDEFINE

DEFINE CLASS timPureAddP as destroyoverhead		
	FUNCTION Adder()
		RETURN this.oCont.AddProperty(this.CurProp(), CREATEOBJECT(this.cObjType))

ENDDEFINE

DEFINE CLASS timRizeAddO as timPureAddO
	FUNCTION Remover()
		RETURN this.oCont.RemoveObject(this.CurProp())
	
ENDDEFINE

DEFINE CLASS timRizeAddP as timPureAddP
	FUNCTION Remover()
		LOCAL lc2Null
		lc2Null = "this.oCont." + this.CurProp()
		STORE Null TO (m.lc2Null)
		
ENDDEFINE

DEFINE CLASS timDownAddO as timRizeAddO	
	lStackDown = .t.
ENDDEFINE

DEFINE CLASS timDownAddP as timRizeAddP	
	lStackDown = .t.
ENDDEFINE
>
>>Also with your experiment with removing via a cursor describing the references - did you minimize the object path similar to the NULL example ?
>
>I'll give this a try.
Previous
Reply
Map
View

Click here to load this message in the networking platform