Thread: [Pyobjc-dev] memory leak
Brought to you by:
ronaldoussoren
From: Daniel L. d. S. <dan...@gm...> - 2011-05-08 17:51:40
|
Hello, I have some python code in a pyobjc app. At some point I want to initialize a NSString : string = NSString.alloc().init() In the terminal I get the following output : /Users/dlsa/code/cirrusstore/client/build/cirrusclient.app/Contents/Resources/menubaractions.py:44: UninitializedDeallocWarning: leaking an uninitialized object of type NSPlaceholderString string = NSString.alloc().init() I have in my objective C bootstrap code the creation of an Auto release pool. If I try : string = NSString.alloc().init().autorelease() I get the same warning. Why does this happen ? |
From: Greg E. <gre...@ca...> - 2011-05-08 21:56:30
|
Daniel Luis dos Santos wrote: > string = NSString.alloc().init() > > /Users/dlsa/code/cirrusstore/client/build/cirrusclient.app/Contents/Resources/menubaractions.py:44: UninitializedDeallocWarning: leaking an uninitialized object of type NSPlaceholderString > string = NSString.alloc().init() Python strings get converted to NSStrings automatically where needed, so is there some reason you can't use an empty Python string instead? -- Greg |
From: Ronald O. <ron...@ma...> - 2011-05-12 12:06:22
Attachments:
smime.p7s
|
On 8 May, 2011, at 19:51, Daniel Luis dos Santos wrote: > Hello, > > I have some python code in a pyobjc app. At some point I want to initialize a NSString : > > string = NSString.alloc().init() Which version of pyobjc do you use? This works for me: >>> from Foundation import NSString s = NSString.string>>> s = NSString.string() >>> s u'' >>> s = NSString.alloc().init() >>> s u'' The PyObjC version can be found using: python -c 'import objc; print(objc.__version__)' Ronald > > In the terminal I get the following output : > > /Users/dlsa/code/cirrusstore/client/build/cirrusclient.app/Contents/Resources/menubaractions.py:44: UninitializedDeallocWarning: leaking an uninitialized object of type NSPlaceholderString > string = NSString.alloc().init() > > > I have in my objective C bootstrap code the creation of an Auto release pool. > > If I try : > > string = NSString.alloc().init().autorelease() > > I get the same warning. > > Why does this happen ? > ------------------------------------------------------------------------------ > WhatsUp Gold - Download Free Network Management Software > The most intuitive, comprehensive, and cost-effective network > management toolset available today. Delivers lowest initial > acquisition cost and overall TCO of any competing solution. > http://p.sf.net/sfu/whatsupgold-sd > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Daniel L. d. S. <dan...@gm...> - 2011-05-12 20:43:37
|
I am using version : faisca:~ dlsa$ python -c 'import objc; print(objc.__version__)' 2.2b3 On May 12, 2011, at 1:05 PM, Ronald Oussoren wrote: > > On 8 May, 2011, at 19:51, Daniel Luis dos Santos wrote: > >> Hello, >> >> I have some python code in a pyobjc app. At some point I want to initialize a NSString : >> >> string = NSString.alloc().init() > > Which version of pyobjc do you use? This works for me: > >>>> from Foundation import NSString > s = NSString.string>>> s = NSString.string() >>>> s > u'' >>>> s = NSString.alloc().init() >>>> s > u'' > > The PyObjC version can be found using: python -c 'import objc; print(objc.__version__)' > > Ronald > >> >> In the terminal I get the following output : >> >> /Users/dlsa/code/cirrusstore/client/build/cirrusclient.app/Contents/Resources/menubaractions.py:44: UninitializedDeallocWarning: leaking an uninitialized object of type NSPlaceholderString >> string = NSString.alloc().init() >> >> >> I have in my objective C bootstrap code the creation of an Auto release pool. >> >> If I try : >> >> string = NSString.alloc().init().autorelease() >> >> I get the same warning. >> >> Why does this happen ? >> ------------------------------------------------------------------------------ >> WhatsUp Gold - Download Free Network Management Software >> The most intuitive, comprehensive, and cost-effective network >> management toolset available today. Delivers lowest initial >> acquisition cost and overall TCO of any competing solution. >> http://p.sf.net/sfu/whatsupgold-sd >> _______________________________________________ >> Pyobjc-dev mailing list >> Pyo...@li... >> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > |
From: Ronald O. <ron...@ma...> - 2011-05-12 12:07:02
Attachments:
smime.p7s
|
On 8 May, 2011, at 23:56, Greg Ewing wrote: > Daniel Luis dos Santos wrote: > >> string = NSString.alloc().init() >> >> /Users/dlsa/code/cirrusstore/client/build/cirrusclient.app/Contents/Resources/menubaractions.py:44: UninitializedDeallocWarning: leaking an uninitialized object of type NSPlaceholderString >> string = NSString.alloc().init() > > Python strings get converted to NSStrings automatically where > needed, so is there some reason you can't use an empty Python > string instead? I don't know why Daniel wants to use an NSString, but there are reasons to use NSString instead of Python unicode strings, for example because NSString has a number of usefull methods with no easy native equivalent. Ronald > > -- > Greg > > ------------------------------------------------------------------------------ > WhatsUp Gold - Download Free Network Management Software > The most intuitive, comprehensive, and cost-effective network > management toolset available today. Delivers lowest initial > acquisition cost and overall TCO of any competing solution. > http://p.sf.net/sfu/whatsupgold-sd > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Greg E. <gre...@ca...> - 2011-05-12 12:15:05
|
Ronald Oussoren wrote: > I don't know why Daniel wants to use an NSString, but there are reasons to > use NSString instead of Python unicode strings, for example because NSString > has a number of usefull methods with no easy native equivalent. But is there a reason to use any of them on an *empty* NSString? -- Greg |
From: Daniel L. d. S. <dan...@gm...> - 2011-05-12 20:47:22
|
You are right about not making much sense in using a NSString this way. I did it out of distraction. My question is still on. Why the warning ? I just want to understand, because I don't get it. Regards, Daniel Santos On May 12, 2011, at 1:14 PM, Greg Ewing wrote: > Ronald Oussoren wrote: >> I don't know why Daniel wants to use an NSString, but there are reasons to >> use NSString instead of Python unicode strings, for example because NSString >> has a number of usefull methods with no easy native equivalent. > > But is there a reason to use any of them on an *empty* NSString? > > -- > Greg > > ------------------------------------------------------------------------------ > Achieve unprecedented app performance and reliability > What every C/C++ and Fortran developer should know. > Learn how Intel has extended the reach of its next-generation tools > to help boost performance applications - inlcuding clusters. > http://p.sf.net/sfu/intel-dev2devmay > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Greg E. <gre...@ca...> - 2011-05-12 23:21:04
|
Daniel Luis dos Santos wrote: > You are right about not making much sense in using a NSString this way. I did it out of distraction. > My question is still on. Why the warning ? It looks like a bug in pyobjc to me. According to the Cocoa docs, [[NSString alloc] init] gives you an empty NSString, so the equivalent in Python ought to work, even if it's not particularly useful. -- Greg |
From: Ronald O. <ron...@ma...> - 2011-05-14 05:40:31
Attachments:
smime.p7s
|
On 12 May, 2011, at 22:47, Daniel Luis dos Santos wrote: > You are right about not making much sense in using a NSString this way. I did it out of distraction. > My question is still on. Why the warning ? I just want to understand, because I don't get it. It's a bug in the copy of PyObjC that's included in OSX 10.6: $ /usr/bin/python Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin Type "help", "copyright", "credits" or "license" for more information. :>>> from Foundation import NSString :>>> NSString.alloc().init() __main__:1: UninitializedDeallocWarning: leaking an uninitialized object of type NSPlaceholderString u'' :>>> s = _ :>>> type(s) <type 'objc.pyobjc_unicode'> :>>> I haven't researched yet why this happens, and later versions work properly. Ronald > > Regards, > Daniel Santos > > On May 12, 2011, at 1:14 PM, Greg Ewing wrote: > >> Ronald Oussoren wrote: >>> I don't know why Daniel wants to use an NSString, but there are reasons to >>> use NSString instead of Python unicode strings, for example because NSString >>> has a number of usefull methods with no easy native equivalent. >> >> But is there a reason to use any of them on an *empty* NSString? >> >> -- >> Greg >> >> ------------------------------------------------------------------------------ >> Achieve unprecedented app performance and reliability >> What every C/C++ and Fortran developer should know. >> Learn how Intel has extended the reach of its next-generation tools >> to help boost performance applications - inlcuding clusters. >> http://p.sf.net/sfu/intel-dev2devmay >> _______________________________________________ >> Pyobjc-dev mailing list >> Pyo...@li... >> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > > ------------------------------------------------------------------------------ > Achieve unprecedented app performance and reliability > What every C/C++ and Fortran developer should know. > Learn how Intel has extended the reach of its next-generation tools > to help boost performance applications - inlcuding clusters. > http://p.sf.net/sfu/intel-dev2devmay > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |