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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:05:01+00:00 2026-06-01T22:05:01+00:00

For one of my last school projects, I am creating an iPad/iPhone application. For

  • 0

For one of my last school projects, I am creating an iPad/iPhone application. For some days now I’ve been working on an issue with a certain memory leak. My application starts out on a specific view-controller (VCMainStatistics_iPad). From there, I push another view-controller (VCSocialMedia_iPad). Afterwards, I go back to the first view-controller.

When I repeat this sequence, I notice (by using Instruments – Activity Monitor) that the memory usage of the app keeps increasing. By disabling parts of the code, I eventually found out it has something to do with the pickerView. This code gives no leaks:

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    return 0;
}

However, when I increase the number of rows, leaks start emerging (roughly 0.07 MB per row). Obviously, this is why I believe the pickerView is the cause of the leaks. I’ve been trying to remove the subviews from the pickerView before deallocation, setting pickerView to nil, and lots of other things… nothing fixes the issue. To hopefully make things a bit clearer, I’ll post some more code.

The header file:

#import "UniversalViewController.h"

#define DATATYPE_SOCIALMEDIA 0

@interface VCSocialMedia_iPad : UniversalViewController <UIPickerViewDataSource, UIPickerViewDelegate>
{
    NSArray *lMediaTypes;
    NSMutableArray *lMediaData;

    __weak IBOutlet UIPickerView *pkSocialMedia;
    __weak IBOutlet UILabel *lblGraph;
}

@end

PickerView delegate methods:

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    // Get key of requested row
    NSString *title = [[lMediaTypes objectAtIndex:row] capitalizedString];

    // Capitalize first letter
    title = [title capitalizedString];

    // Return
    return title;
}



- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    // Make or clear data lists
    if( lGraphDayDataX[iSelectedServerIndex][DATATYPE_SOCIALMEDIA] == nil ){
        lGraphDayDataX[iSelectedServerIndex][DATATYPE_SOCIALMEDIA] = [[NSMutableArray alloc] init];
    }
    else{
        [lGraphDayDataX[iSelectedServerIndex][DATATYPE_SOCIALMEDIA] removeAllObjects];
    }

    if( lGraphDayDataY[iSelectedServerIndex][DATATYPE_SOCIALMEDIA] == nil ){
        lGraphDayDataY[iSelectedServerIndex][DATATYPE_SOCIALMEDIA] = [[NSMutableArray alloc] init];
    }
    else{
        [lGraphDayDataY[iSelectedServerIndex][DATATYPE_SOCIALMEDIA] removeAllObjects];
    }

    // Get required key
    NSString *dictKey = [lMediaTypes objectAtIndex:row];

    if( [dictKey isEqualToString:@"total_views"] ){
        return;
    }

    // Adjust graph label
    lblGraph.text = [NSString stringWithFormat:@"Stats from %@", dictKey];

    // Get data of selected row
    NSArray *mediaData = [lMediaData objectAtIndex:row];

    // Add each day to data lists: inversed order
    for( int day = [mediaData count]-1; day >= 0; day-- ){
        NSDictionary *dayData = [mediaData objectAtIndex:day];
        dictKey = @"wpsd_trends_date";

        NSString *date = [dayData objectForKey:dictKey];
        // Remove 00:00:00
        date = [date stringByReplacingOccurrencesOfString:@" 00:00:00" withString:@""];
        [lGraphDayDataX[iSelectedServerIndex][DATATYPE_SOCIALMEDIA] addObject:date];

        dictKey = @"wpsd_trends_stats";
        NSString *stats = [dayData objectForKey:dictKey];
        [lGraphDayDataY[iSelectedServerIndex][DATATYPE_SOCIALMEDIA] addObject:stats];
    }

    // Update the graphs
    [self updateGlobalScreen];
}

PickerView datasource methods:

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}



- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    return [lMediaTypes count];
}

Deallocation:

- (void)dealloc
{
    pkSocialMedia = nil;
    lblGraph = nil;

    lMediaData = nil;
    lMediaTypes = nil;
}

I only recently converted the project to Objective-C ARC, so there is a good chance this issue has something to do with my lack of experience with the concept. Apart from that, this is also my first Xcode project ever. Hopefully, someone here can help out: please let me know if I need to post more code to clarify things.

Thanks in advance!

  • 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-06-01T22:05:04+00:00Added an answer on June 1, 2026 at 10:05 pm

    Never found the solution itself, so I used a workaround: by replacing the NSPickerView with a NSTableView component, the leak did not occur anymore. For everyone who noticed the issue and tried to find a solution: thank you for trying!

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

Sidebar

Related Questions

Now with all the WaitOne and ManualResetEvent stuff working (thanks!) I've got one last
I'm working on a school assignment and I'm having an issue with a 2d
I've been working on a project that involves ajax; it's a planner for school
I am trying to get one last thing working: I have a blog link
I am working on a patching system and I have one last bug i
I am working on a projection utility and have one last (more?) hurdle to
I did some timing tests and also read some articles like this one (last
OK, I thought I would try one last update and see if it gets
I'm nearly done with a trackback system for my website, but have one last
We are currently evaluating upgrading from XP to Windows 7, but have one last

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.