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

  • Home
  • SEARCH
  • 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 991237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:04:38+00:00 2026-05-16T06:04:38+00:00

I am getting memory leak at text fiels please suggest me how to resolve

  • 0

I am getting memory leak at text fiels please suggest me how to resolve it.

I written the code in init() as:

            eventTextField = nil;
    eventTextField = [[UITextField alloc]initWithFrame:CGRectMake(10, 15, 300, 50)];
    eventTextField.placeholder = @"Event Name";
    [eventTextField setFont:[UIFont boldSystemFontOfSize:14]];
    eventTextField.returnKeyType = UIReturnKeyDone;
    eventTextField.keyboardAppearance  = UIKeyboardAppearanceDefault;//Showing leak at this line
    eventTextField.keyboardType = UIKeyboardTypeDefault;
    eventTextField.delegate=self;

and I released it in dealloc method.

and in cellForRowIndex I am adding it as subview.

- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MasterViewIdentifier"];
if (cell == nil) 
{
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"MasterViewIdentifier"] autorelease];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    UIView* elementView =  [[UIView alloc] initWithFrame:CGRectMake(20,170,320,280)];
    elementView.tag = 0;
    elementView.backgroundColor=[UIColor clearColor];
    [cell.contentView addSubview:elementView];
    [elementView release];
}
UIView* elementView  = [cell.contentView viewWithTag:0];
elementView.backgroundColor=[UIColor clearColor];
for(UIView* subView in elementView.subviews)
{
    [subView removeFromSuperview];
}
if(indexPath.section == 0 && indexPath.row == 0)
{
    CorkItAppDelegate* appDelegate = (CorkItAppDelegate*)[[UIApplication sharedApplication] delegate];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    wineNameTitleLabel.numberOfLines = 0;
    [wineNameTitleLabel setFont:[UIFont boldSystemFontOfSize:14]];

    if(appDelegate.isNewWine == YES)
    {
        wineNameTitleLabel.textColor = [UIColor blackColor] ;
        wineNameTitleLabel.text = appDelegate.getNewWineName;
    }
    else
    {
        if([event.eventWineName length]>0)
        {
            wineNameTitleLabel.textColor = [UIColor blackColor] ;
            wineNameTitleLabel.text = event.eventWineName;
        }
        else
        {
            wineNameTitleLabel.text = @"Wine Name";
        }
    }
        [elementView addSubview:wineNameTitleLabel];
}

else if(indexPath.section == 1)
{

    if(isRightButton == YES)
    {
        eventTextField.enabled = NO;
    }
    else
    {
        eventTextField.enabled = YES;
    }
    if([event.eventName length] > 0)
    {
        eventTextField.text = event.eventName;
    }
    else
    {
        eventTextField.text = @"";
    }
    [elementView addSubview:eventTextField];
    cell.accessoryType = UITableViewCellAccessoryNone;
}
       return cell;
 }

Hope I get wucik response from your side.
Thanks in advance,
Monish.

  • 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-16T06:04:39+00:00Added an answer on May 16, 2026 at 6:04 am

    If you still need the eventTextField. You should create a property and instance variable for it. So that, you can your class own the eventTextField and release it in the dealloc. Like this:

    @interface A {
      UITextField *eventTextField;
    }
    
    @property (nonatomic, retain) UITextField *eventTextField;
    
    @end
    
    @implementation A
    @synthesize eventTextField;
    
    - (id)init {
      eventTextField = [[UITextField alloc]init];
    }
    
    - (void)dealloc {
      [eventTextField release];
    }
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here Im Getting memory leak at eventTextField.keyboardAppearance = UIKeyboardAppearanceDefault; I declared the textfield globally
I'm getting the memory leak message upon shutdown, saying that I'm leaking 3 of
I'm trying to use the CRT memory leak detection but I keep getting the
I have been getting a weird memory leak and i just pinpointed what is
HI, I am getting memory leak at NSObject allocation i.e., ContactDTO* contactDTO = [[ContactDTO
I am getting a memory leak in a method that builds a email message
I have just been getting into low level programming (reading/writing to memory that sort
I can't find a cause for a memory leak in my application. I found
I am having a memory leak problem and it is actually generating from the
When i run the instrument tool i'm getting memory leaks in the following lines,(NSString

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.