<HTML>
<HEAD>
<TITLE>[V4CC] VTable.Field() Vcursor.Field() and no leaks. </TITLE>
</HEAD>
<BODY>
<FONT FACE="Lucida Grande"><SPAN STYLE='font-size:11pt'>Hi Erne,<BR>
Hi Thorsten,<BR>
<BR>
Today I have made attempt reproduce any leaks in V4CC with help of <BR>
[tbl FieldAtIndex:i]<BR>
[curs FieldAtIndex:i]<BR>
<BR>
And I have not found any leaks guys.<BR>
I still think you have some mirage :-)<BR>
<BR>
So I have take V4CC/Example/Sql_Way/Records_AddDeleteUpdate<BR>
<BR>
==============================================<BR>
Then I have change method pbSelect to be as <BR>
<BR>
- (IBAction)pbSelect:(id)sender<BR>
{<BR>
@try<BR>
{ <BR>
for( int i = 1; i <= 100 ; ++i )<BR>
{<BR>
VTable* pTable = [mDatabase tableForName:@"T1"];<BR>
<BR>
int Count = [pTable fieldCount];<BR>
for( int i = 1; i <= Count ; ++i )<BR>
{<BR>
VField* pFld = [pTable fieldAtIndex:i];<BR>
} <BR>
} <BR>
}<BR>
@catch(NSException* pe)<BR>
{<BR>
[mwPropertyPanel showError:[pe name] reason:[pe reason]];<BR>
}<BR>
}<BR>
<BR>
==============================================<BR>
- (IBAction)pbSelect:(id)sender<BR>
{<BR>
@try<BR>
{ <BR>
NSString* query = @"SELECT * FROM T1 WHERE false";<BR>
<BR>
for( int i = 1; i <= 100 ; ++i )<BR>
{<BR>
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];<BR>
<BR>
VCursor* pCursor = [mDatabase sqlSelect:query cursorLocation:EVCursorLocation_kServerSide <BR>
lockType:EVLockType_kReadWrite direction:EVCursorDirection_kRandom];<BR>
<BR>
int Count = [pCursor fieldCount];<BR>
for( int i = 1; i <= Count ; ++i )<BR>
{<BR>
VField* pFld = [pCursor fieldAtIndex:i];<BR>
} <BR>
<BR>
[pool release];<BR>
} <BR>
}<BR>
@catch(NSException* pe)<BR>
{<BR>
[mwPropertyPanel showError:[pe name] reason:[pe reason]];<BR>
}<BR>
}<BR>
<BR>
<BR>
<BR>
AS you can see in first case I test VTable and in the second Vcursor.<BR>
<BR>
1) Note that Vtable* and Vfield* never are retained, released or autoreleases.<BR>
No need for this because of internal structure and tricks<BR>
<BR>
There is nothing bad here guys, because RULES of course are rules,<BR>
But they also mention that in some cases, IF YOU KNOW something special,<BR>
you can avoid do extra retain/release calls.<BR>
<BR>
Here we have exactly such special case.<BR>
VDatabase is a root of tree of schema objects. <BR>
VDatabase keeps tables and links. Tables keep fields, ...<BR>
V4CC designed in such way that we do not have overheads here.<BR>
<BR>
<BR>
And only when Vdatabase object — ROOT will be release <BR>
And start destroy self it will destroy the whole tree, including both<BR>
KERNEL objects and wow! V4CC cocoa objects.<BR>
<BR>
<BR>
<BR>
2) VCursor test above is shown with NSAutoReleasePool usage.<BR>
<BR>
VCursor is one more ROOT of tree, like VDatabase. <BR>
VCursor keeps set of fields and is their owner. <BR>
NOT you. NOT your classes. VCursor is owner. <BR>
<BR>
So you can take fields by simple line:<BR>
VField* pFld = [pCursor fieldAtIndex:i];<BR>
<BR>
And no need for any special steps here. <BR>
No need retain, no need release.<BR>
<BR>
<BR>
===========================================<BR>
Once again, I have run this modified example project to search <BR>
Zombies, and later Leaks.<BR>
<BR>
No Zombies.<BR>
No Leaks... There was only few minor by singlentons in vkernel.<BR>
<BR>
If you still think that something is wrong, please <BR>
Take above example, copy above my code.<BR>
Modify code to expose problem, and describe steps to see that problem.<BR>
<BR>
<BR>
-- <BR>
Best regards,<BR>
<BR>
Ruslan Zasukhin<BR>
VP Engineering and New Technology<BR>
Paradigma Software, Inc<BR>
<BR>
Valentina - Joining Worlds of Information <BR>
<a href="http://www.paradigmasoft.com">http://www.paradigmasoft.com</a><BR>
<BR>
[I feel the need: the need for speed]<BR>
</SPAN></FONT>
</BODY>
</HTML>