• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: The released object is not releasing memory
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: The released object is not releasing memory


  • Subject: RE: The released object is not releasing memory
  • From: Vinay Prabhu <email@hidden>
  • Date: Mon, 14 May 2007 19:46:02 +0530
  • Importance: Normal

I have checked for retainCount for "bmp" before releasing it. The retain
count is 2.
Does the API "graphicsContextWithBitmapImageRep" will retain NSBitmapRep?

-Vinay

-----Original Message-----
From: Mike Abdullah [mailto:email@hidden]
Sent: Monday, May 14, 2007 5:44 PM
To: Vinay Prabhu
Cc: email@hidden
Subject: Re: The released object is not releasing memory


I would strongly advise you use a proper tool for measuring your
memory management; not Activity Monitor. I suggest looking at
ObjectAlloc for a start.

Bear in mind there is no guarantee that Cocoa will release the memory
straight away; the system may well perform some caching for you.

Mike.

On 14 May 2007, at 10:46, Vinay Prabhu wrote:

> Hi,
>
> I am trying draw into the bitmap rep directly.
> Here is the code. At the end, I am releasing the NSBitmapImageRep.
> When I debug this peace of code, I was monitoring the memory usage in
> Activity Monitor.
> When I create the object, the memory usage increases, but when I
> release the
> object, the memory occupied has not reduced.
>
> So is there anything extra needs to be taken care here?
>
> NSBitmapImageRep * bmp = [[NSBitmapImageRep alloc]
> initWithBitmapDataPlanes:nil
> 										pixelsWide:m_uiWidth
> 										pixelsHigh:m_uiHeight
> 										 bitsPerSample:8
> 										   samplesPerPixel:4
> 							  hasAlpha:YES
> 							  isPlanar:NO
> 						colorSpaceName:NSDeviceRGBColorSpace
> 						   bytesPerRow:(4*m_uiWidth)
> 						  bitsPerPixel:32];
>
> NSRect fillRect = NSMakeRect(0, 0, m_uiWidth, m_uiHeight);
>
> NSGraphicsContext* currentContext = [NSGraphicsContext
> currentContext];
> NSGraphicsContext* bitmapContext = [NSGraphicsContext
> graphicsContextWithBitmapImageRep:bmp];
>
> [NSGraphicsContext saveGraphicsState];
> [NSGraphicsContext setCurrentContext:bitmapContext];
>
> //Drawing code here
> [[NSColor colorWithCalibratedRed:0 green:0 blue:0 alpha:0] set];
> NSRectFillUsingOperation(fillRect, NSCompositeSourceOver);
>
> [NSGraphicsContext setCurrentContext:currentContext];
> [NSGraphicsContext restoreGraphicsState];
>
> [bmp  release];
>
> Regards
> Vinay
>
>
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> 40mikeabdullah.net
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: The released object is not releasing memory
      • From: Scott Ribe <email@hidden>
References: 
 >Re: The released object is not releasing memory (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: sleep problem when mounting a windows volume
  • Next by Date: Re: RS: autorelease with no pool in place
  • Previous by thread: Re: The released object is not releasing memory
  • Next by thread: Re: The released object is not releasing memory
  • Index(es):
    • Date
    • Thread