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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:12:15+00:00 2026-05-15T17:12:15+00:00

I am getting allocation count plus one in the below code. – (UITableViewCell *)tableView:(UITableView

  • 0

I am getting allocation count plus one in the below code.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];
    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"MasterViewIdentifier"] autorelease];
        cell.accessoryType = UITableViewCellAccessoryNone;
        cell.selectionStyle = UITableViewCellEditingStyleNone;
        UIView* elementView =  [ [UIView alloc] initWithFrame:CGRectMake(5,5,312,480)];
        elementView.tag = 0;
        [cell.contentView addSubview:elementView];
        [elementView release];
    }
    UIView* elementView  = [cell.contentView viewWithTag:0];
    for(UIView* subView in elementView.subviews)
    {
        [subView removeFromSuperview];
    }

    if(indexPath.section==0)
    {
        if(indexPath.row==0)
        {
                   // i have tried like this but getting exception.
            /*
            UIImage *cellBackImag=[UIImage imageNamed:@"celltop.png" ];
            UIImageView* imaeView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 300, 43)];
            imaeView.image=cellBackImag;
            [elementView addSubview:imaeView];
            [imaeView release];
            [cellBackImag release];
             */


            // here I am getting uiimage count allocation count 
            UIImageView* imaeView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"celltop.png" ]];
            imaeView.frame=CGRectMake(0, 0, 300, 43);
            [elementView addSubview:imaeView];
            [imaeView release];

Please help me out of this, Thank You,
Madan Mohan

  • 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-15T17:12:16+00:00Added an answer on May 15, 2026 at 5:12 pm

    First of all you should not rely on the retain count, because when you pass the object to some method all things might happen with this object, like someone retains it, autoreleases it again, passes it to another method, etc, etc. So the value is highly inaccurate.

    But here in your case, the retain count of (at least) +1 is correct, because you want your image view to remain alive after you added it as a subview to elementView, so [element addSubview:imageView] retains your image view (adding +1 to the retain count) and then you release it again (leaving the +1 from alloc init).

    The reason why you get the exception with the commented out code is that you create an autoreleased object for cellBackImag and then you release it. After your method returns, at some point the autorelease pool will release the image again, and there it will crash.

    So basically just stick with the second approach (alloc, init, add, release) and forget about the retain count. If you’re worried about memory leaks, you should take a look at Instruments, which is a great tool for finding all kinds of bugs.

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

Sidebar

Ask A Question

Stats

  • Questions 506k
  • Answers 506k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It turns out that writing your own custom object that… May 16, 2026 at 3:44 pm
  • Editorial Team
    Editorial Team added an answer You may try something like that: rake test_rake_task SOME_PARAM=value1,value2,value3 And… May 16, 2026 at 3:44 pm
  • Editorial Team
    Editorial Team added an answer You want to build your own DE (desktop environment). Common… May 16, 2026 at 3:44 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am getting leaks in Master view controller of iPhone. When I call this
I'm trying to get a record count of a table in sqlite3 on the
I am trying to find dynamically and statically instantiated objects number. I am getting
I am getting such a crash: #0 0x90b05955 in __gnu_debug::_Safe_iterator_base::_M_detach #1 0x90b059ce in __gnu_debug::_Safe_iterator_base::_M_attach
Why am I getting this error: Error 1 error C2662: 'Allocator::Allocate' : cannot convert
I am getting an error when I declare a class: #include <iostream> #include testing/test.h
When in doubt, turn to Stackoverflow... I'm having a problem with string allocation. My
gcc 4.4.4 c89 valgrind 3.5.0. I am getting a leak detected when I open
Getting a NSString as follows: NSString *lastSyncDate = [[items objectAtIndex:0] objectForKey:@LastSyncDate]; This value is:
Getting super frustrated trying to get this working. Basically this is for a site

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.