Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CURSOR Experiencing Memo Bloat
Message
 
 
To
15/07/2006 10:31:11
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
01136610
Message ID:
01136733
Views:
12
Cetin,

That really isn't a valid test for cursor memo bloat. There's a 50/50 chance that each replace is going to require a new memo block allocation because the memo field is longer, so of course you'll see a big file constantly growing but it doesn't have 1000 memo block allocations in it.
set blocksize to 0
create table employee ( id i, notes m )
insert into employee values ( 1, "" )

SELECT * FROM employee INTO CURSOR xxEmployee readwrite

select xxEmployee

? "starting must bloat it"
set step on

FOR ix = 1 TO 1000
   replace notes WITH REPLICATE('X',ix * 1000) in xxEmployee
ENDFOR

? len( xxEmployee.notes )

set step on

? "starting won't bloat it phase"

FOR ix = 1 TO 1000
   replace notes WITH REPLICATE('X',(1000-ix) * 1000) in xxEmployee
ENDFOR

? len( xxEmployee.notes )
at the midpoint of execution I have a 409,152kb file in my temp folder. the whole second half of the code execution does not increase the size one iota.

If I run this slightly modified junk of your code:
set blocksize to 0
create table employee ( id i, notes m )
insert into employee values ( 1, "" )

SELECT * FROM employee INTO CURSOR xxEmployee readwrite

FOR ix = 1 TO 1000
   replace notes WITH REPLICATE('X',INT(RAND()*1000000))
ENDFOR
The tmp file is sitting at 254,565 mb showing that indeed some memo reuse occurred with the tmp file slightly larger that 1/2 of the one from my code above.

Overall I do agree with you, using a SCATTER NAME xxEmployee object would be one heck of a lot faster and not suffer from bloat at all.

I suspect there's got to be a better way of getting to the memo's final ultimate value without going through 1000s of intermediate values REPLACEd into the memo.

>>I cannot use a memory variable. The table is referenced recursively directly in hundreds of places.
>
>You cannot? I could do that easily. Ok here is a sample:
>
>SELECT * FROM employee INTO CURSOR xxEmployee readwrite
>start = SECONDS()
>FOR ix = 1 TO 1000
>replace notes WITH REPLICATE('X',INT(RAND()*1000000))
>ENDFOR
>? SECONDS()-m.start
>
Keep an eye in task manager and temp folder. You'd see memo file going sky high (F5 at least once or you wouldn't).
>Now try with:
>
>SELECT * FROM employee INTO CURSOR xxEmployee readwrite
>SCATTER NAME oRec memo
>start = SECONDS()
>FOR ix = 1 TO 1000
>oRec.Notes = REPLICATE('X',INT(RAND()*1000000))
>ENDFOR
>? SECONDS()-m.start
>
Again checking in task manager.
>First took over 17secs on my box. While the latter is under 1 sec with no negligible impact on memory/paging etc.
>I don't understand why you can't use object instead.
>Cetin
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform