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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:00:43+00:00 2026-05-31T16:00:43+00:00

Can someone tell me what I am doing wrong here? I use this method

  • 0

Can someone tell me what I am doing wrong here? I use this method to draw image. But something in the code seems to not be released properly because every-time I call a this method and my application memory footprint increases.

Here,I am providing method which increase my memory.

-(void)imagemaking
{
UIGraphicsEndImageContext();
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];

SBJSON *parser = [[SBJSON alloc] init];

statuses = [parser objectWithString:responseString
                              error:nil];
[parser release];


networkConnection.image = [UIImage imageNamed:@"NetworkTrans1.png"];


[updateTimeClock setImage:[UIImage imageNamed:@"GreenClock.png"] forState:UIControlStateNormal];

NSArray *segment = [[NSArray alloc]init];
segment = [statuses valueForKey:@"Segments"];

int linewidth = 3;

CGSize polyimagesize = CGSizeMake(self.mapView.frame.size.width , self.mapView.frame.size.height);

UIGraphicsBeginImageContextWithOptions(polyimagesize, NO, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, linewidth);

CGContextSetAlpha(context, 0.6);    

for(NSDictionary *route in segment) {

    NSString *locations = [route valueForKey:@"Locations"];

    if (locations && ([locations length]/16 > 1)) {       

        UIColor *color = [UIColor blueColor];
        CGContextSetStrokeColorWithColor(context, color.CGColor);

        for (int i = 0; i <= locations.length - 32; i += 32) {

            CLLocationCoordinate2D coordinates;
            coordinates.latitude = hexDecode_iPhone([locations substringWithRange:NSMakeRange(i, 16)]);
            coordinates.longitude = hexDecode_iPhone([locations substringWithRange:NSMakeRange(i+16, 16)]);

            CGPoint point = [mapView convertCoordinate:coordinates toPointToView:self.mapView];

            if (i == 0)
                CGContextMoveToPoint(context, point.x, point.y);
            else
                CGContextAddLineToPoint(context, point.x, point.y);
        }

        CGContextStrokePath(context);

    }        
}       

madeimage =  UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();
[responseString release];   
[segment release];

}

As per my Investigation,Memory foot print increase because of CoreGraphics.But i don’t know how to reduce memory usage or which object is increase the memory usage.Please provide guide-line .

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-05-31T16:00:44+00:00Added an answer on May 31, 2026 at 4:00 pm

    You are assigning [statuses valueForKey:@”Segments”]; to segment and loosing address previously allocated by [[NSArray alloc]init];

    NSArray *segment = [[NSArray alloc]init]; //Array #1
    segment = [statuses valueForKey:@"Segments"]; //Array #2 (replaces #1)
    

    Final release is not aware of previously allocated memory address; it can only release array #2.

    [segment release];
    

    So the statement that causes the first array to be leaked is at:

    segment = [statuses valueForKey:@"Segments"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi can someone tell me what i'm doing wrong in this jquery statement. I
Can someone tell me what i am doing wrong here? I want the boxes
Can someone please tell me what I am doing wrong here? <script type=text/javascript> (document).ready(function()
can someone tell me what i am doing wrong here.. i am not getting
Can someone tell me what I am doing wrong here? I simplified it below
can someone please tell what I'm doing wrong here? \newcommand{\bc}{\small\begin{verbatim}} \newcommand{\ec}{\normalsize\end{verbatim}} and then \bc
Please can someone tell me what im doing wrong here with respect to calling
Can someone who is way smarter than I tell me what I'm doing wrong..
Can someone tell me how to change directories using FtpWebRequest? This seems like it
Can someone tell what is wrong with this query? sqltext = SELECT utyp, count(*)

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.