<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Ruslan,<div><br></div><div>thanks for taking the time to dig into this issue.</div><div><br></div><div><br></div><div>I've followed your exact steps and cursor example produces a lot of leaks here:</div><div><br></div><div><div>Leaked Object<span class="Apple-tab-span" style="white-space:pre"> </span>#<span class="Apple-tab-span" style="white-space:pre"> </span>Address<span class="Apple-tab-span" style="white-space:pre"> </span>Size<span class="Apple-tab-span" style="white-space:pre"> </span>Responsible Library<span class="Apple-tab-span" style="white-space:pre"> </span>Responsible Frame</div><div>< multiple ><span class="Apple-tab-span" style="white-space:pre"> </span>556<span class="Apple-tab-span" style="white-space:pre"> </span>< multiple ><span class="Apple-tab-span" style="white-space:pre"> </span>8896<span class="Apple-tab-span" style="white-space:pre"> </span>V4CC<span class="Apple-tab-span" style="white-space:pre"> </span>MakeREALInstance(fbl::smart_ptr<fbl::I_Field>)</div><div>Malloc 16 Bytes<span class="Apple-tab-span" style="white-space:pre"> </span>506<span class="Apple-tab-span" style="white-space:pre"> </span>< multiple ><span class="Apple-tab-span" style="white-space:pre"> </span>8096<span class="Apple-tab-span" style="white-space:pre"> </span>libvshared_fat_release.dylib<span class="Apple-tab-span" style="white-space:pre"> </span>fbl_new(unsigned long, bool)</div><div>Malloc 16 Bytes<span class="Apple-tab-span" style="white-space:pre"> </span>40<span class="Apple-tab-span" style="white-space:pre"> </span>< multiple ><span class="Apple-tab-span" style="white-space:pre"> </span>640<span class="Apple-tab-span" style="white-space:pre"> </span>libvkernel_fat_release.dylib<span class="Apple-tab-span" style="white-space:pre"> </span>yyFlexLexer::yylex()</div><div>Malloc 16 Bytes<span class="Apple-tab-span" style="white-space:pre"> </span>40<span class="Apple-tab-span" style="white-space:pre"> </span>< multiple ><span class="Apple-tab-span" style="white-space:pre"> </span>640<span class="Apple-tab-span" style="white-space:pre"> </span>libvkernel_fat_release.dylib<span class="Apple-tab-span" style="white-space:pre"> </span>yyFlexLexer::yylex()</div><div>Malloc 16 Bytes<span class="Apple-tab-span" style="white-space:pre"> </span>37<span class="Apple-tab-span" style="white-space:pre"> </span>< multiple ><span class="Apple-tab-span" style="white-space:pre"> </span>592<span class="Apple-tab-span" style="white-space:pre"> </span>libvkernel_fat_release.dylib<span class="Apple-tab-span" style="white-space:pre"> </span>yyFlexLexer::yylex()</div><div>Malloc 16 Bytes<span class="Apple-tab-span" style="white-space:pre"> </span> <span class="Apple-tab-span" style="white-space:pre"> </span>0x1999120<span class="Apple-tab-span" style="white-space:pre"> </span>16<span class="Apple-tab-span" style="white-space:pre"> </span>libvkernel_fat_release.dylib<span class="Apple-tab-span" style="white-space:pre"> </span>yyFlexLexer::yylex()</div><div>Malloc 16 Bytes<span class="Apple-tab-span" style="white-space:pre"> </span> <span class="Apple-tab-span" style="white-space:pre"> </span>0x1999040<span class="Apple-tab-span" style="white-space:pre"> </span>16<span class="Apple-tab-span" style="white-space:pre"> </span>libvkernel_fat_release.dylib<span class="Apple-tab-span" style="white-space:pre"> </span>yyFlexLexer::yylex()</div></div><div><br></div><div>and this is on first click only, every click produces ever more leaked objects!</div><div><br></div><div>This is the report produced if I only add "autorelease" to this line: </div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #7031a7"><span class="Apple-tab-span" style="white-space:pre"> </span></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #7031a7"><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"> </span>VField</span>* pFld = [[pCursor <span style="color: #3f0c7f">fieldAtIndex</span>:i] <span style="color: #3f0c7f">autorelease</span>];</div></div><div><br></div><div><div>Leaked Object<span class="Apple-tab-span" style="white-space:pre"> </span>#<span class="Apple-tab-span" style="white-space:pre"> </span>Address<span class="Apple-tab-span" style="white-space:pre"> </span>Size<span class="Apple-tab-span" style="white-space:pre"> </span>Responsible Library<span class="Apple-tab-span" style="white-space:pre"> </span>Responsible Frame</div><div>Malloc 16 Bytes<span class="Apple-tab-span" style="white-space:pre"> </span>57<span class="Apple-tab-span" style="white-space:pre"> </span>< multiple ><span class="Apple-tab-span" style="white-space:pre"> </span>912<span class="Apple-tab-span" style="white-space:pre"> </span>libvkernel_fat_release.dylib<span class="Apple-tab-span" style="white-space:pre"> </span>yyFlexLexer::yylex()</div><div>Malloc 16 Bytes<span class="Apple-tab-span" style="white-space:pre"> </span>53<span class="Apple-tab-span" style="white-space:pre"> </span>< multiple ><span class="Apple-tab-span" style="white-space:pre"> </span>848<span class="Apple-tab-span" style="white-space:pre"> </span>libvkernel_fat_release.dylib<span class="Apple-tab-span" style="white-space:pre"> </span>yyFlexLexer::yylex()</div><div>Malloc 16 Bytes<span class="Apple-tab-span" style="white-space:pre"> </span>52<span class="Apple-tab-span" style="white-space:pre"> </span>< multiple ><span class="Apple-tab-span" style="white-space:pre"> </span>832<span class="Apple-tab-span" style="white-space:pre"> </span>libvkernel_fat_release.dylib<span class="Apple-tab-span" style="white-space:pre"> </span>yyFlexLexer::yylex()</div><div>Malloc 16 Bytes<span class="Apple-tab-span" style="white-space:pre"> </span> <span class="Apple-tab-span" style="white-space:pre"> </span>0x1964410<span class="Apple-tab-span" style="white-space:pre"> </span>16<span class="Apple-tab-span" style="white-space:pre"> </span>libvkernel_fat_release.dylib<span class="Apple-tab-span" style="white-space:pre"> </span>yyFlexLexer::yylex()</div><div>Malloc 16 Bytes<span class="Apple-tab-span" style="white-space:pre"> </span> <span class="Apple-tab-span" style="white-space:pre"> </span>0x1964330<span class="Apple-tab-span" style="white-space:pre"> </span>16<span class="Apple-tab-span" style="white-space:pre"> </span>libvkernel_fat_release.dylib<span class="Apple-tab-span" style="white-space:pre"> </span>yyFlexLexer::yylex()</div></div><div><br></div><div>as you can see the number of leaked objects is much much smaller...</div><div><br></div><div>if I comment out the VField casting loop I get this on about every click:</div><div><br></div><div><div>Leaked Object<span class="Apple-tab-span" style="white-space:pre"> </span>#<span class="Apple-tab-span" style="white-space:pre"> </span>Address<span class="Apple-tab-span" style="white-space:pre"> </span>Size<span class="Apple-tab-span" style="white-space:pre"> </span>Responsible Library<span class="Apple-tab-span" style="white-space:pre"> </span>Responsible Frame</div><div>Malloc 16 Bytes<span class="Apple-tab-span" style="white-space:pre"> </span>99<span class="Apple-tab-span" style="white-space:pre"> </span>< multiple ><span class="Apple-tab-span" style="white-space:pre"> </span>1584<span class="Apple-tab-span" style="white-space:pre"> </span>libvkernel_fat_release.dylib<span class="Apple-tab-span" style="white-space:pre"> </span>yyFlexLexer::yylex()</div><div>Malloc 16 Bytes<span class="Apple-tab-span" style="white-space:pre"> </span>98<span class="Apple-tab-span" style="white-space:pre"> </span>< multiple ><span class="Apple-tab-span" style="white-space:pre"> </span>1568<span class="Apple-tab-span" style="white-space:pre"> </span>libvkernel_fat_release.dylib<span class="Apple-tab-span" style="white-space:pre"> </span>yyFlexLexer::yylex()</div><div>Malloc 16 Bytes<span class="Apple-tab-span" style="white-space:pre"> </span>97<span class="Apple-tab-span" style="white-space:pre"> </span>< multiple ><span class="Apple-tab-span" style="white-space:pre"> </span>1552<span class="Apple-tab-span" style="white-space:pre"> </span>libvkernel_fat_release.dylib<span class="Apple-tab-span" style="white-space:pre"> </span>yyFlexLexer::yylex()</div></div><div><br></div><div>which seems to consistently report about 3 objects leak on every cursor creation...</div><div><br></div><div><br></div><div>I'm happy to confirm that the field casting from VTable produces very clean results i.e. no leaks at all!</div><div><br></div><div><br></div><div>I've made no check for zombies, since I never seen one and I'm too scared of such an otherwordly encounter! :-)</div><div><br></div><div>Just joking of course, maybe Thorsten can shed some light on this one.</div><div><br></div><div><br></div><div>Cool Runnings,</div><div>Erne.</div><div><br></div><div><br><div><div>On Sep 3, 2010, at 16:57, Ruslan Zasukhin wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>
<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>
</div>
_______________________________________________<br>Valentina mailing list<br><a href="mailto:Valentina@lists.macserve.net">Valentina@lists.macserve.net</a><br><a href="http://lists.macserve.net/mailman/listinfo/valentina">http://lists.macserve.net/mailman/listinfo/valentina</a><br></blockquote></div><br></div></body></html>