ImageKit + GC = nogo? (or better... how :D)

  • Hi,
    I have build a small sample app - following the example code given in
    the doku about it.
    Nothing facy: a browser and an image view  (my addition to the sample)
    then I tested with my ~/Pictures ( lets say..... 15000)

    NO GC
    All is fine! Memory usage is quite constant for my tests.

    WITH GC
    Then I went and set GC to required for my app.
    (Code; no more retain/release calls  - for this test.... but that
    shouldn't influence ImageKit)

    Checked if GC is enabled for my app and all its Libs by adding
    OBJ_PRINT_GC=YES to my build path. All looking good.

    But now my memory usage constantly gets higher and once I run out of
    RAM things go down (as they tend to do when you leak ... )

    So.. what am I doing wrong?
    I can't believe that Framework is so 'buggy' and therefore I am
    curiose as to where I made a mistake. Maybe even a totallyobvious one
    I forgot... like...... have I to do more than require GC in build
    settings to make it active?

    Thanks,
    Dominik

    BTW: Code and performance samples can be provided :) My code is
    actually REALLY simple, no threading - nothing. (See ImageKit sample)
  • On Dec 1, 2007, at 10:21 AM, Dominik Pich wrote:
    > So.. what am I doing wrong?
    > I can't believe that Framework is so 'buggy' and therefore I am
    > curiose as to where I made a mistake. Maybe even a totallyobvious
    > one I forgot... like...... have I to do more than require GC in
    > build settings to make it active?
    >
    > Thanks,
    > Dominik
    >
    > BTW: Code and performance samples can be provided :) My code is
    > actually REALLY simple, no threading - nothing. (See ImageKit sample)

    Please file a bug.

    I suspect that this is a known bug in ImageKit but, as always, another
    concise test case is quite welcome.  As well, there is the off-chance
    that you have run across something new.

    thanks,
    b.bum
  • Hi,

    I see the same issue. But ImageKit may not be responsible.
    I wrote a simple loop that creates thumbnails using ImageIO .

    NO GC
    All is fine: memory usage at the end of the loop : 4.93Mo

    WITH GC:
    the memory usage constantly gets higher : at the end of the loop:
    785.12 Mo

    Also using ImageKit with GC turned on but without ImageIO (by showing
    iconRefs for instance) doesn't seems to leak.
    So the issue seems to be in ImageIO or at a lower level.

    I filed a new bug.

    -- thomas

    (the code for my test:)
    {
        int i;

        NSURL *url = [[NSURL alloc] initFileURLWithPath:@"/Library/
    Desktop Pictures/Nature/Ladybug.jpg"];

        NSDictionary *optionsDict = [[NSDictionary alloc]
    initWithObjectsAndKeys:[NSNumber numberWithInt:
    (int)128],kCGImageSourceThumbnailMaxPixelSize,

    kCFBooleanTrue,kCGImageSourceCreateThumbnailFromImageIfAbsent,

    kCFBooleanTrue,kCGImageSourceCreateThumbnailWithTransform,

    kCFBooleanFalse,kCGImageSourceShouldCache,
                                                            nil,nil];

    for(i=0; i<400; i++){
      id pool = [[NSAutoreleasePool alloc] init];

      CGImageSourceRef sourceRef =
    CGImageSourceCreateWithURL((CFURLRef)url, nil);
      CGImageRef thumbnail =
    CGImageSourceCreateThumbnailAtIndex(sourceRef, 0,
    (CFDictionaryRef)optionsDict);

      CGImageRelease(thumbnail);
      CFRelease(sourceRef);

      [pool drain];
      [pool release];
    }

    [optionsDict release];
    [url release];
    }

    On Dec 1, 2007, at 7:21 PM, Dominik Pich wrote:

    > Hi,
    > I have build a small sample app - following the example code given
    > in the doku about it.
    > Nothing facy: a browser and an image view  (my addition to the sample)
    > then I tested with my ~/Pictures ( lets say..... 15000)
    >
    > NO GC
    > All is fine! Memory usage is quite constant for my tests.
    >
    > WITH GC
    > Then I went and set GC to required for my app.
    > (Code; no more retain/release calls  - for this test.... but that
    > shouldn't influence ImageKit)
    >
    > Checked if GC is enabled for my app and all its Libs by adding
    > OBJ_PRINT_GC=YES to my build path. All looking good.
    >
    > But now my memory usage constantly gets higher and once I run out of
    > RAM things go down (as they tend to do when you leak ... )
    >
    > So.. what am I doing wrong?
    > I can't believe that Framework is so 'buggy' and therefore I am
    > curiose as to where I made a mistake. Maybe even a totallyobvious
    > one I forgot... like...... have I to do more than require GC in
    > build settings to make it active?
    >
    > Thanks,
    > Dominik
    >
    > BTW: Code and performance samples can be provided :) My code is
    > actually REALLY simple, no threading - nothing. (See ImageKit sample)
  • On Dec 2, 2007, at 9:14 AM, Thomas Goossens wrote:
    > Hi,
    >
    > I see the same issue. But ImageKit may not be responsible.
    > I wrote a simple loop that creates thumbnails using ImageIO .
    >
    > NO GC
    > All is fine: memory usage at the end of the loop : 4.93Mo
    >
    > WITH GC:
    > the memory usage constantly gets higher : at the end of the loop:
    > 785.12 Mo
    >
    > Also using ImageKit with GC turned on but without ImageIO (by
    > showing iconRefs for instance) doesn't seems to leak.
    > So the issue seems to be in ImageIO or at a lower level.
    >
    > I filed a new bug.

    Thank you.  This is the known issue and was what I suspected the OP
    was probably encountering.

    Though a duplicate, that you provided a concise example is very much
    appreciated!

    b.bum
  • On 12/2/07, Thomas Goossens <tgoossens...> wrote:
    > Hi,
    >
    > I see the same issue. But ImageKit may not be responsible.
    > I wrote a simple loop that creates thumbnails using ImageIO .
    >
    > NO GC
    > All is fine: memory usage at the end of the loop : 4.93Mo
    >
    > WITH GC:
    > the memory usage constantly gets higher : at the end of the loop:
    > 785.12 Mo
    >
    > Also using ImageKit with GC turned on but without ImageIO (by showing
    > iconRefs for instance) doesn't seems to leak.
    > So the issue seems to be in ImageIO or at a lower level.
    >
    > I filed a new bug.
    >
    > -- thomas
    >
    >
    > (the code for my test:)
    > {
    > int i;
    >
    > NSURL *url = [[NSURL alloc] initFileURLWithPath:@"/Library/
    > Desktop Pictures/Nature/Ladybug.jpg"];
    >
    > NSDictionary *optionsDict = [[NSDictionary alloc]
    > initWithObjectsAndKeys:[NSNumber numberWithInt:
    > (int)128],kCGImageSourceThumbnailMaxPixelSize,
    >
    > kCFBooleanTrue,kCGImageSourceCreateThumbnailFromImageIfAbsent,
    >
    > kCFBooleanTrue,kCGImageSourceCreateThumbnailWithTransform,
    >
    > kCFBooleanFalse,kCGImageSourceShouldCache,
    > nil,nil];
    >
    > for(i=0; i<400; i++){
    > id pool = [[NSAutoreleasePool alloc] init];
    >
    > CGImageSourceRef sourceRef =
    > CGImageSourceCreateWithURL((CFURLRef)url, nil);
    > CGImageRef thumbnail =
    > CGImageSourceCreateThumbnailAtIndex(sourceRef, 0,
    > (CFDictionaryRef)optionsDict);
    >
    > CGImageRelease(thumbnail);
    > CFRelease(sourceRef);
    >
    > [pool drain];
    > [pool release];
    > }
    >
    > [optionsDict release];
    > [url release];
    > }

    Do you see the same memory leak if you use
    CGImageSourceCreateWithData() instead of CGImageSourceCreateWithURL()?
    I have an application which used CGImageSourceCreateWithURL() and it
    always kept the file open even after I had realeased everything.  Once
    I switched to loading the file into an NSData object and then creating
    the CGImageSourceRef every cleaned up nicely.

    Isaac
  • >
    > Do you see the same memory leak if you use
    > CGImageSourceCreateWithData() instead of CGImageSourceCreateWithURL()?
    > I have an application which used CGImageSourceCreateWithURL() and it
    > always kept the file open even after I had realeased everything.  Once
    > I switched to loading the file into an NSData object and then creating
    > the CGImageSourceRef every cleaned up nicely.

    There is no leak if I use CGImageSourceCreateWithData() instead of
    CGImageSourceCreateWithURL().

    -- Thomas.
  • No good when using imagekit :/
    I tried different representations.... all leak there...

    Am Dec 2, 2007 um 10:48 PM schrieb Thomas Goossens:

    >>
    >> Do you see the same memory leak if you use
    >> CGImageSourceCreateWithData() instead of
    >> CGImageSourceCreateWithURL()?
    >> I have an application which used CGImageSourceCreateWithURL() and it
    >> always kept the file open even after I had realeased everything.
    >> Once
    >> I switched to loading the file into an NSData object and then
    >> creating
    >> the CGImageSourceRef every cleaned up nicely.
    >
    > There is no leak if I use CGImageSourceCreateWithData() instead of
    > CGImageSourceCreateWithURL().
    >
    > -- Thomas.
  • The following representations will leak with GC turned on because they
    are using ImageIO to create thumbnails at some point:
    extern NSString * const IKImageBrowserPathRepresentationType;                /*
    NSString */
    extern NSString * const IKImageBrowserNSURLRepresentationType;                /*
    NSURL */
    extern NSString * const
    IKImageBrowserCGImageSourceRepresentationType;        /* CGImageSourceRef */
    extern NSString * const IKImageBrowserNSDataRepresentationType;                /*
    NSData */
    extern NSString * const
    IKImageBrowserQuickLookPathRepresentationType;        /* NSString or NSURL*/

    I don't know about the other representations.

    -- Thomas.

    On Dec 3, 2007, at 2:06 PM, Dominik Pich wrote:

    > No good when using imagekit :/
    > I tried different representations.... all leak there...
    >
    > Am Dec 2, 2007 um 10:48 PM schrieb Thomas Goossens:
    >
    >>>
    >>> Do you see the same memory leak if you use
    >>> CGImageSourceCreateWithData() instead of
    >>> CGImageSourceCreateWithURL()?
    >>> I have an application which used CGImageSourceCreateWithURL() and it
    >>> always kept the file open even after I had realeased everything.
    >>> Once
    >>> I switched to loading the file into an NSData object and then
    >>> creating
    >>> the CGImageSourceRef every cleaned up nicely.
    >>
    >> There is no leak if I use CGImageSourceCreateWithData() instead of
    >> CGImageSourceCreateWithURL().
    >>
    >> -- Thomas.
    >
  • On 12/1/07 7:21 PM, Dominik Pich said:

    > Checked if GC is enabled for my app and all its Libs by adding
    > OBJ_PRINT_GC=YES to my build path. All looking good.

    May I ask: is OBJ_PRINT_GC something of yours or some Apple-provided
    debugging thingie?

    Thanks,

    --
    ____________________________________________________________
    Sean McBride, B. Eng                <sean...>
    Rogue Research                        www.rogue-research.com
    Mac Software Developer              Montréal, Québec, Canada
  • It's a variable you can add to you executable environment. (Sorry I
    said build path)
    It is mentioned in the GC progamming reference and is purely apple.

    Regards,
    Dominik

    Am Dec 3, 2007 um 4:40 PM schrieb Sean McBride:

    > On 12/1/07 7:21 PM, Dominik Pich said:
    >
    >> Checked if GC is enabled for my app and all its Libs by adding
    >> OBJ_PRINT_GC=YES to my build path. All looking good.
    >
    > May I ask: is OBJ_PRINT_GC something of yours or some Apple-provided
    > debugging thingie?
    >
    > Thanks,
    >
    > --
  • On 12/3/07 5:22 PM, Dominik Pich said:

    > It's a variable you can add to you executable environment. (Sorry I
    > said build path)
    > It is mentioned in the GC progamming reference and is purely apple.

    Thanks.  I did google and search Xcode's built-in docs before posting,
    and all I found was your post. :)

    --
    ____________________________________________________________
    Sean McBride, B. Eng                <sean...>
    Rogue Research                        www.rogue-research.com
    Mac Software Developer              Montréal, Québec, Canada
previous month december 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today