Justin we need your help on V4CC about cursor kill
Ruslan Zasukhin
sunshine at public.kherson.ua
Tue Dec 23 08:39:43 CST 2008
On 12/23/08 2:05 PM, "Justin Drury" <justin at soundminer.com> wrote:
Hi Justin,
Thank you for reply. I CC to Valentina list. I think discussion can be
interesting to others.
1) idea of NSAutoreleasePool looks to be the only real legal way...
Hmm. And does it work fast?
2) so you vote strictly against remove autorelease?
3) The most strange thing for me is that they do not give us real way
control WHEN we release resources used by objects as RECORD LOCKS.
If I not mistake in NET to resolve this issue, each class inherits method
Dispose(), which we can call to FORCE object release everything. After this
call object becomes invalid.
May be you have hear about such tips for ObjC development?
4) db.SqlSelect() -- I cannot name this method as GET method.
it is FACTORY. This method create new instance of object.
If we call it 10 times we get 10 new objects.
GET method return 10 times ref to the same object.
GetField(), getTAble(), ...
agree?
The same is true for
Database, Cursor, Sets, SetIterator
It is not true for
Table, Field, IndexStyle, Link,
5) I am not sure I agree with you that retain is bad style in our case.
I read this page and I do not read such strict rule that returned object
MUST be autoreleased... Can you give me some points.
http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Concept
s/ObjectOwnership.html#//apple_ref/doc/uid/20000043
6) will be great if you will be online and we talk more about this not in
rush way...
> Hi Ruslan, the easiest is to put in AutoreleasePools(this is where
> abojects that are released/autoreleased) are killed
>
> so
>
> NSAutoreleasePool *killPool=[[NSAutoreleasePool alloc]init];
> VCursor *curs=[db sqlSelect:@"the query"];
> // do stuff
> [killPool release];
>
> curs=[db sqlSelect:@"the query"];
>
> I have a scoped call I use a lot as I use Objective C++
>
>
> class AutoPool
> {
> public:
> AutoPool() { pool = [[NSAutoreleasePool alloc] init]; }
> ~AutoPool() { [pool release]; }
> private:
> NSAutoreleasePool* pool;
> };
>
> ....so....
> VCursor *curs=0;
> {
> AutoPool killPool;
> curs=[db sqlSelect:@"the query"];
> // do stuff and pool is released when it goes out of scope.
> }
> {
> AutoPool killPool;
> curs=[db sqlSelect:@"the query"];
> }
>
> I think it would be weird(and against convention) to use
> retain/release. Any object that returns is always presumed to be
> autoreleased, unless it was explicitly created(the old "Apple" rules on
> creation...ie CFStringCreate(you need to release) CFStringGet(you
> don't). I think of VCursor as a "GET"
>
> I don't think OBJ-C allows function overloading if it did you could get
> the retainCount and do any clean up. Perhaps a smart_ptr type
> clear/reset function could be added?
>
> Hope that helps
>
> Justin
>
>
>
> Ruslan Zasukhin wrote:
>> Hi Justin,
>>
>> We se that in V4CC code cursors on creation are marked now as autorelease,
>>
>> But then we get troubles, because we cannot kill it in momemnt when we need
>> this.
>>
>> For example:
>>
>> Func()
>> {
>> curs = db.SqlSelectr()
>>
>> use it here
>> now I want use again the same variable.
>>
>> curs = db.SqlSelect() <<<<< boom cursor live yet here.
>> RECORD LOCK issue.
>>
>> }
>>
>> In REALbasic and NET and Java we have control how kill it right now
>>
>> Func()
>> {
>> curs = db.SqlSelectr()
>>
>> use it here
>> now I want use again the same variable.
>>
>> curs = nil << really killed here
>>
>> curs = db.SqlSelect()
>>
>> }
>>
>>
>> May be for OBJC also exists such way ?
>>
>>
>> If no then I believe I will need throw away this autoreleases everywhere in
>> V4CC and return back to release/retain way.
>>
>>
>>
>
--
Best regards,
Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc
Valentina - Joining Worlds of Information
http://www.paradigmasoft.com
[I feel the need: the need for speed]
More information about the Valentina
mailing list