Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3804910
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:35:38+00:00 2026-05-19T14:35:38+00:00

I have a few, full screen, UIColor PatternImages (in scrollViews ) in my iPad

  • 0

I have a few, full screen, UIColor PatternImages (in scrollViews) in my iPad app and am experiencing some memory problems (surprise?)
When I started having memory issues, I implemented lazy loading in my scrollviews.
When the problems continued, I moved away from factory methods
(like [UIColor colorWithPatternImage:...])
to “alloc”ed methods
(like [[UIColor alloc]initWithPatternImage:...]),
so I could respond to memory warnings by releasing pages.

However, whenever I release my UIColor PatternImages, I get an “EXC_BAD_ACCESS” error.

At first I thought this might be caused by my [UIImage imageNamed:...] pattern images, so I switched to [[UIImage alloc]initWithContentsOfFile:...] images, but this didn’t help. Just now I set NSZombiesEnabled and it tells me that the problem is:

-[UICGColor release]: message sent to deallocated instance 0x187b50

With the backtrace:

#0  0x35823910 in ___forwarding___ ()
#1  0x35823860 in __forwarding_prep_0___ ()
#2  0x357e53c8 in CFRelease ()
#3  0x357e48de in _CFAutoreleasePoolPop ()
#4  0x3116532c in NSPopAutoreleasePool ()
#5  0x341a7508 in _wrapRunLoopWithAutoreleasePoolHandler ()
#6  0x3580ac58 in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#7  0x3580aacc in __CFRunLoopDoObservers ()
#8  0x358020ca in __CFRunLoopRun ()
#9  0x35801c86 in CFRunLoopRunSpecific ()
#10 0x35801b8e in CFRunLoopRunInMode ()
#11 0x320c84aa in GSEventRunModal ()
#12 0x320c8556 in GSEventRun ()
#13 0x341dc328 in -[UIApplication _run] ()
#14 0x341d9e92 in UIApplicationMain ()
#15 0x00002e5e in main (argc=1, argv=0x2fdff610) at...

I don’t have any UICGColor objects either, so I’m thinking that somehow my “alloc”ed UIColors have underlying UICGColor autorelease objects…? Any ideas/insight?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T14:35:38+00:00Added an answer on May 19, 2026 at 2:35 pm

    OK, I have worked something out, thanks in part to the (poorly tagged and titled) SO question/answers here. What I needed to do was read-up about UIView.backgroundColor. In my docs it says @property(nonatomic, copy) UIColor *backgroundColor. The “copy” here tells me that when I say something like:

    myUIView.backgroundColor=[[UIColor alloc]initWithPatternImage:myUIImage];
    

    The myUIView.backgroundColor is actually a different object to the [[UIColor alloc]initWithPatternImage:myUIImage]. This separate myUIView.backgroundColor is, in fact, autoreleased, so when I go [myUIView.backgroundColor release]; I am actually shooting myself in the foot. What I need to do is:

    UIColor* tmpColor=[[UIColor alloc]initWithPatternImage:myUIImage];
    currentPage.backgroundColor=tmpColor;
    [tmpColor release];
    

    (and of course, around that, I’m also allocing and releasing myUIImage). Now to release my scrollView patternImage, I can just do something like currentPage.backgroundColor=nil; (like @BuildSucceeded) or currentPage.backgroundColor=[UIColor clearColor]; (not sure if there is a practical difference). I guess internally, both of these cause currentPage to autorelease the old backgroundColor. Since making these changes, I haven’t been able to get my app to crash.

    I need to say this: I don’t think C++ does it quite right, but C# and Java both manage quite nicely without any of this complicated release, autorelease, @property business. Of course, if someone wanted to implement an analogous (to Objective-C) pointer management system in Java or C# they could, but of course no one wants this because it would be pretty useless. Pleeeease Apple, migrate away from Objective-C!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few scripts on a site I recently started maintaining. I get
I have few asynchronous tasks running and I need to wait until at least
I have few different applications among which I'd like to share a C# enum.
I'm a newbie to pgsql. I have few questionss on it: 1) I know
How do I create subdomains in ASP.NET? I have few links on my homepage(Home.aspx)
We have a few very large Excel workbooks (dozens of tabs, over a MB
I have a few Visual Studio Solutions/Projects that are being worked on in my
I have a few C# .dll projects which are common to many applications. Currently,
We have a few projects that involve building an application that is composed of
I have a few lines of PowerShell code that I would like to use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.