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 3974048
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:31:21+00:00 2026-05-20T04:31:21+00:00

Preamble: The view controller’s view I’m talking about is used in a UISplitViewController as

  • 0

Preamble:
The view controller’s view I’m talking about is used in a UISplitViewController as the details view. It gets replaced if the user navigates using the UINavigationController of the split view. When hitting “Back”, a new instance of my problematic view controller is created and gets assigned to the split view controllers array of controllers.
Everytime my view shows up, I see an 8MB block being allocated in Instruments. Navigating forth and back for a while will eventually crash the app.

In detail:

In my class overriding UIViewController I have a:

private UIColor oBgColor = null;

in ViewDidLoad():

    this.oBgColor = UIColor.FromPatternImage ( UIImage.FromFile ( "Data/Images/background.jpg" ) );
// This line here causes memory to go up by 8MB!
    this.View.BackgroundColor = this.oBgColor;

in ViewDidDisappear():

// These lines should sucessfully get rid of the allocated 8MB chunk.    
this.View.BackgroundColor = UIColor.Clear;
    this.oBgColor.Dispose();
    this.View.Dispose();

Code reaches ViewDidDisappear() as expected, view is gone.

The 8MB block is allocated ONLY if I assign this.oBgColor to the view’s BackgroundColor. Leave that line out and all works (but I don’t have a background).
Each time the view gets shown, I see another 8MB getting wasted.

What’s going on here? Is BackgroundImage known to be leaking?

Interesting sidenote: if I add a UIImageView as a subview and use its image instead of assign to the view BackgroundColor property, memory hardly goes up at all and gets properly released.

  • 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-20T04:31:22+00:00Added an answer on May 20, 2026 at 4:31 am

    I wrote a sample based on your code, and while memory usage does go up when it is assigned, there is no leak (I toggled the image on and off 100 times, and memory didn’t change).

    The reason it goes up is the BackgroundImage property is backed by a copy @property in Objective-C, which means that the entire object is copied on assignment, so if you have a huge pattern image, and then assign it, you will for a brief period have 2 copies of the image in memory.

    The reason you see the memory increase is as I explained to you on IRC, MonoTouch does not have a compacting GC in v3.

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

Sidebar

Related Questions

Preamble: I am aware of using a list or other collections to return a
I am using ntheorem to typeset a set of conditions. In my preamble I
Preamble: All data connection strings, connections, etc are created using DbProviderFactories. Code is mixed
Colleagues, Preamble. My question is more about best practices. I know one workaround. This
Preamble I'm using git as a version control system for a paper that my
Preamble Using VTK library with C++, quite often I have to write something like
Preamble: I am using ASP.NET 3.5 and AJAXControlToolkit. I am trying to use the
A preamble: I've been using PHP for over 8 year every now and then,
Preamble To build dynamic web-sites, we have to master at least four languages: HTML
Small preamble. I was good java developer on 1.4 jdk. After it I have

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.