Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Object vs. array?
Message
From
26/08/2009 11:53:42
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01420180
Message ID:
01420831
Views:
76
>>>Hi,
>>>
>>>I am using arrays as way to pass the information from UI to BIZ/DA objects but thinking about changing to objects (using SCATTER/GATHER). In terms of memory use, do objects require more memory?
>>
>>About
>>array ~ 16 bytes/item or more
>>obj property~ 104 bytes/item or more
>>
>
>Hi Fabio,
>
>I am curious; how do you determine in VFP the memory size of this or that object? Say I have an object oMyObj, is there a function in VFP that will tell you that?

sys(1011) and sys(1016)

I do not have time to do analysis on VFP,
but just putting any eye on its operation,
bugs appear immediately.

Here you see as REMOVEPROPERTY() produce a Memory leak ( VFP9 SP2 )
clear
CLEAR ALL
memstart = 0
memstart = VAL(SYS(1016))
FOR j=1 TO 10
? "heap handles",SYS(1011),' '
	FOR h=1 TO 10000
		k= SPACE(10000)
		RELEASE k
		DIMENSION X[100]
		X = SPACE(20000)
		RELEASE x
		ox=CREATEOBJECT("empty")
		ADDPROPERTY(m.ox,"p",SPACE(20000))	
		RELEASE ox
	NEXT
NEXT
RELEASE J,H
? "memory used",VAL(SYS(1016))-m.memstart

memstart = VAL(SYS(1016))
FOR j=1 TO 10
? "heap handles",SYS(1011),' '
	FOR h=1 TO 10000
		k=1
		RELEASE k
		DIMENSION X[100]
		RELEASE x
		ox=CREATEOBJECT("empty")
		ADDPROPERTY(m.ox,"p",SPACE(20000))		&& allocate 2 memory handles : 1 x metadata + 1 x data
		REMOVEPROPERTY(m.ox,"p")			&& this leave the data block (20000 bytes) allocated
		RELEASE ox
	NEXT
NEXT
RELEASE J,H
? "memory used", VAL(SYS(1016))-m.memstart

CLEAR ALL && this doesn't clear the Memory leak
? "heap handles",SYS(1011)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform