[iPhone + OpenGL ES]  - glDrawElements memory leak!?

Hello -
I found in the Leaks tool that when glDrawElements is called, a huge chunk of memory gets allocated. This memory is the exact size of a texture that was already loaded earlier. (1024x1024xRGBA = 4mb)
There is no other resource in the app that it could be, except another allocation of that texture. So instead of seeing 4mb in Leaks, I see 8mb - the second allocation being done by gfxAllocateTextureLevel.
If I comment out glDrawElements, this problem does not occur.
This is all on the simulator. I can't tell if it happens on the phone because Leaks crashes when I use it on the device.. Any ideas?

typewriter wrote:
This is all on the simulator. I can't tell if it happens on the phone because Leaks crashes when I use it on the device.. Any ideas?
You probably have nothing to worry about. The simulator runs VERY differently than the real hardware.
For instance, as I was porting our company's game engine to the iPhone Simulator, I had to give the global heap an extra 5 megabytes, for memory allocations coming from Apple's threads. On the real iPhone, it needs less than 15k.
I've had one of our games running in a "demo loop" for hours on the real iPhone, with no crashes or other weird problems. So I doubt the iPhone's OpenGL is leaking memory.
Hope this helps.

Similar Messages

  • [iPhone] UICachedDeviceWhiteColor showing as memory leak in Leaks

    Leaks reports UICachedDeviceWhiteColor as a leak in my app.
    It is generally shows as a leak after I release a UIViewController that I've pushed onto the main navigationController.
    I can't find a reference to UICachedDeviceWhiteColor anywhere.
    Has anyone else seen this mysterious UICachedDeviceWhiteColor?

    minax wrote:
    I had similar problem. After lots of trial-and-error I figured out that "Info Light" button - which was added using IB - on my navigation bar's right bar button item caused this.
    So I removed "Info Light" button from XIB and create it programmatically, and then the UICachedDeviceWhiteColor is finally disappeared.
    After seeing this post, I tried the same thing and sure enough it works! Delete the info light button and replace it with a different UIButton and my leak totally disappered.
    Thanks for the help!

  • GlDrawArrays leaks memory? (iPhone OpenGL ES)

    Using the leaks instrument, the glDrawArrays function seems to cause a bunch of memory leaks. This happens even in the GLSprite example project from apple (and also in my projects, as they are based on that). Commenting out that function alone fixes the leak (but of course prevents anything from being drawn).
    Is this an opengl-es bug, or a bug in the code?

    The memory leak only appears when running in the simulator, no leaks appear on the actual hardware (iPod Touch 2.0). Seems to be some problem with OpenGL in the simulator.

  • Memory leak issue in iPhone app

    We developed a little program to display PDF's on the iPhone, but it's crashing after scrolling through xx number of pages with low memory error. The app runs fine in the simulator but crashes on the original iphone. I ran the memory leak debugger tool from xcode and got the following:
    http://picasaweb.google.com/momopi/MiscCollection#5384555524546579922
    (click on magnify glass tool to zoom in)
    Weird part is when I run the same on iphone simulator I only get 2 small memory leak warnings (128 bytes each), but on the iphone I get a lot more warnings and it crashes.
    Has anyone seen anything like this?

    Perhaps you don't have any meaningful leaks. Your program could simply consume too much memory. It has been many years since keeping a small memory footprint was important. Now that Apple has thrown embedded programming to the masses, everyone has forgotten about that.

  • [iPhone] Memory leak when UIWebview is loaded with URL

    I have created a custom browser in my app using UIWebview . A memory leak is seen on everytime webview is loaded with provided  url. A snapshot of the leak is shown below.You may note that no back trace is shown and hence cause of leak is unknown.
    Snapshot of leak
    Please help me with this issue as early as possible.

    You might want to take this discussion to the developers forums. This is a general user to user forum for using the iPhone. This is way outside the scope of general use.

  • SslIoRead memory leak in NSOutputStream (iPhone SDK)

    Hi, I am using NSOutputStream to write email to smtp server. I used TLSv1 as security protocol. I found that everytime I open such a output stream and output as TLSv1, there is about 36k memory leak from a call "sslIoRead". Perfermance tool aslo link it to something like this in the code:
    [outputStream setProperty:NSStreamSocketSecurityLevelTLSv1 forKey:NSStreamSocketSecurityLevelKey]
    Anyone as the same experience, how can I fix it?
    Thank you very much.

    Added code in a more readable fashion:
    CGImageRef blockRef = CGImageCreateWithImageInRect([img CGImage], CGRectMake(imgWidth - clipx, clipy,texsize,texsize));
    CGContextRef spriteContext = CGBitmapContextCreate(spriteData, tex_size, tex_size, 8, tex_size * 4, CGImageGetColorSpace(blockRef), kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
    CGContextDrawImage(spriteContext, CGRectMake(0,0,(CGFloat)tex_size, (CGFloat)tex_size), blockRef);
    glGenTextures(1, &texref);
    glBindTexture(GLTEXTURE2D, texref);
    glTexImage2D(GLTEXTURE2D, 0, GL_RGBA, 512, 512, 0, GL_RGBA, GLUNSIGNEDBYTE, spriteData);
    glTexParameterx(GLTEXTURE2D, GLTEXTURE_MINFILTER, GL_LINEAR);
    glTexParameterx(GLTEXTURE2D, GLTEXTURE_MAGFILTER, GL_LINEAR);
    CGImageRelease(blockRef);
    CGContextRelease(spriteContext);

  • IPhone: OpenGL ES Texturing

    I just began writing an iPhone game and I'm having difficulties displaying multiple textures.
    Only the last texture I generate is appearing and all the textures I generated previously appear white.
    Here is major rendering functions so far, is there anything that stands out as incorrect?
    //Generates textures for a game object
    - (void)GenerateTextures:(Hairball::Objects)Obj
    CGImageRef spriteImage;
    CGContextRef spriteContext;
    GLubyte *spriteData;
    size_t width, height;
    GLuint *tempTex;
    // Creates a Core Graphics image from an image file
    switch (Obj)
    case Hairball::PLAYER:
    spriteImage = [UIImage imageNamed:@"Sprite.png"].CGImage;
    tempTex = &(TextureArray[0]);
    break;
    case Hairball::BACKGROUND:
    spriteImage = [UIImage imageNamed:@"BG1.png"].CGImage;
    tempTex = &(TextureArray[1]);
    break;
    case Hairball::HUD:
    spriteImage = [UIImage imageNamed:@"Icon.png"].CGImage;
    tempTex = &(TextureArray[2]);
    break;
    default:
    break;
    // Get the width and height of the image
    width = CGImageGetWidth(spriteImage);
    height = CGImageGetHeight(spriteImage);
    if(spriteImage)
    // Allocated memory needed for the bitmap context
    spriteData = (GLubyte *) malloc(width * height * 4);
    // Uses the bitmatp creation function provided by the Core Graphics framework.
    spriteContext = CGBitmapContextCreate(spriteData, width, height, 8, width * 4, CGImageGetColorSpace(spriteImage), kCGImageAlphaPremultipliedLast);
    // After you create the context, you can draw the sprite image to the context.
    CGContextDrawImage(spriteContext, CGRectMake(0.0, 0.0, (CGFloat)width, (CGFloat)height), spriteImage);
    // You don't need the context at this point, so you need to release it to avoid memory leaks.
    CGContextRelease(spriteContext);
    // Use OpenGL ES to generate a name for the texture.
    glGenTextures(1, tempTex);
    // Bind the texture name.
    glBindTexture(GLTEXTURE2D, *tempTex);
    // Speidfy a 2D texture image, provideing the a pointer to the image data in memory
    glTexImage2D(GLTEXTURE2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GLUNSIGNEDBYTE, spriteData);
    // Release the image data
    free(spriteData);
    //Inits OpenGl for drawing
    - (void)setupView
    //Creates object Manager to handle
    ObjectMgr = new ObjectManager();
    //Create Objects
    GameObject* Object1 = new GameObject(Hairball::BACKGROUND, 0.0f, 0.0f, 0.0f, 0.0f, 3.2f, 3.2f);
    ObjectMgr->AddToList(Object1);
    GameObject* Object2 = new GameObject(Hairball::PLAYER, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f);
    ObjectMgr->AddToList(Object2);
    //Generate all textures
    [self GenerateTextures:Hairball::PLAYER];
    [self GenerateTextures:Hairball::BACKGROUND];
    //For each obj assign a texture
    std::list<GameObject*>::iterator Object = (ObjectMgr->mObjectList.begin());
    std::list<GameObject*>::iterator End = (ObjectMgr->mObjectList.end());
    //For each game object
    while(Object != End)
    //Apply texture to each object
    switch ((*Object)->mObjectType)
    case Hairball::PLAYER: (*Object)->mSpriteTexture = TextureArray[0]; break;
    case Hairball::BACKGROUND: (*Object)->mSpriteTexture = TextureArray[1]; break;
    case Hairball::HUD: (*Object)->mSpriteTexture = TextureArray[2]; break;
    default:
    break;
    ++Object;
    // Clears the view with grey
    glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
    // Set the texture parameters to use a minifying filter and a linear filer (weighted average)
    glTexParameteri(GLTEXTURE2D, GLTEXTURE_MINFILTER, GL_LINEAR);
    // Enable use of the texture
    glEnable(GLTEXTURE2D);
    // Set a blending function to use
    glBlendFunc(GL_ONE, GLONE_MINUS_SRCALPHA);
    // Enable blending
    glEnable(GL_BLEND);
    - (void)drawView
    [EAGLContext setCurrentContext:context];
    glBindFramebufferOES(GLFRAMEBUFFEROES, viewFramebuffer);
    glViewport(0, 0, backingWidth, backingHeight);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrthof(-1.0f, 1.0f, -1.5f, 1.5f, -1.0f, 1.0f);
    glMatrixMode(GL_MODELVIEW);
    //Clear the backbuffer
    glClear(GLCOLOR_BUFFERBIT);
    std::list<GameObject*>::iterator Object = (ObjectMgr->mObjectList.begin());
    std::list<GameObject*>::iterator End = (ObjectMgr->mObjectList.end());
    //For each game object
    while(Object != End)
    // Bind the texture name.
    glBindTexture(GLTEXTURE2D, (*Object)->mSpriteTexture);
    //apply transformations
    glPushMatrix();
    glTranslatef((*Object)->mPosition.x, (*Object)->mPosition.y, (*Object)->mPosition.z);
    glRotatef((*Object)->mRotation, 0.0f, 0.0f, 1.0f);
    (*Object)->mRotation += 0.5f; //Rotate
    //Get current sprites verticies
    glVertexPointer(2, GL_FLOAT, 0, (*Object)->mSpriteVertices);
    glEnableClientState(GLVERTEXARRAY);
    //Get current sprites tex coords
    glTexCoordPointer(2, GL_SHORT, 0, (*Object)->mSpriteTexcoords);
    glEnableClientState(GLTEXTURE_COORDARRAY);
    //Render the vertex array
    glDrawArrays(GLTRIANGLESTRIP, 0, 4);
    //pop the transformation matrix
    glPopMatrix();
    ++Object;
    glBindRenderbufferOES(GLRENDERBUFFEROES, viewRenderbuffer);
    [context presentRenderbuffer:GLRENDERBUFFEROES];
    }

    The value generated by glGenTextures() in (*Object)->mSpriteTexture for the BACKGROUND object is 1 and for the sprite object it is 2. Which appear to be correct values?
    If I exchange:
    self GenerateTextures:Hairball::PLAYER;
    self GenerateTextures:Hairball::BACKGROUND;
    To
    self GenerateTextures:Hairball::BACKGROUND;
    self GenerateTextures:Hairball::PLAYER;
    then my scene goes from this:
    http://img207.imageshack.us/img207/8229/picture1nf6.png
    to this:
    http://img253.imageshack.us/img253/5282/picture2gr8.png
    So both textures draw, just not at the same time?
    Oh, here it is formatted better:
    //Generates textures for a game object
    - (void)GenerateTextures:(Hairball::Objects)Obj
    CGImageRef spriteImage;
    CGContextRef spriteContext;
    GLubyte *spriteData;
    size_t width, height;
    int texIndex = 0;
    // Creates a Core Graphics image from an image file
    switch (Obj)
    case Hairball::PLAYER:
    spriteImage = [UIImage imageNamed:@"Sprite.png"].CGImage;
    texIndex = 0;
    break;
    case Hairball::BACKGROUND:
    spriteImage = [UIImage imageNamed:@"BG1.png"].CGImage;
    texIndex = 1;
    break;
    case Hairball::HUD:
    spriteImage = [UIImage imageNamed:@"Icon.png"].CGImage;
    texIndex = 2;
    break;
    default:
    break;
    // Get the width and height of the image
    width = CGImageGetWidth(spriteImage);
    height = CGImageGetHeight(spriteImage);
    if(spriteImage)
    // Allocated memory needed for the bitmap context
    spriteData = (GLubyte *) malloc(width * height * 4);
    // Uses the bitmatp creation function provided by the Core Graphics framework.
    spriteContext = CGBitmapContextCreate(spriteData, width, height, 8, width * 4, CGImageGetColorSpace(spriteImage), kCGImageAlphaPremultipliedLast);
    // After you create the context, you can draw the sprite image to the context.
    CGContextDrawImage(spriteContext, CGRectMake(0.0, 0.0, (CGFloat)width, (CGFloat)height), spriteImage);
    // You don't need the context at this point, so you need to release it to avoid memory leaks.
    CGContextRelease(spriteContext);
    // Bind the texture name.
    glBindTexture(GLTEXTURE2D, TextureArray[texIndex]);
    // Speidfy a 2D texture image, provideing the a pointer to the image data in memory
    glTexImage2D(GLTEXTURE2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GLUNSIGNEDBYTE, spriteData);
    // Release the image data
    free(spriteData);
    //Inits OpenGl for drawing
    - (void)setupView
    //Creates object Manager to handle
    ObjectMgr = new ObjectManager();
    //Create Objects
    GameObject* Object1 = new GameObject(Hairball::BACKGROUND, 0.0f, 0.0f, 0.0f, 0.0f, 3.2f, 3.2f);
    ObjectMgr->AddToList(Object1);
    GameObject* Object2 = new GameObject(Hairball::PLAYER, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f);
    ObjectMgr->AddToList(Object2);
    //Generate all textures
    glGenTextures(NUMTEXTURES, TextureArray); // Use OpenGL ES to generate a name for the texture.
    [self GenerateTextures:Hairball::BACKGROUND];
    [self GenerateTextures:Hairball::PLAYER];
    //For each obj assign a texture
    std::list<GameObject*>::iterator Object = (ObjectMgr->mObjectList.begin());
    std::list<GameObject*>::iterator End = (ObjectMgr->mObjectList.end());
    //For each game object
    while(Object != End)
    //Apply texture to each object
    switch ((*Object)->mObjectType)
    case Hairball::PLAYER: (*Object)->mSpriteTexture = TextureArray[0]; break;
    case Hairball::BACKGROUND: (*Object)->mSpriteTexture = TextureArray[1]; break;
    case Hairball::HUD: (*Object)->mSpriteTexture = TextureArray[2]; break;
    default:
    break;
    ++Object;
    // Clears the view with grey
    glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
    // Set the texture parameters to use a minifying filter and a linear filer (weighted average)
    glTexParameteri(GLTEXTURE2D, GLTEXTURE_MINFILTER, GL_LINEAR);
    // Enable use of the texture
    glEnable(GLTEXTURE2D);
    // Set a blending function to use
    glBlendFunc(GL_ONE, GLONE_MINUS_SRCALPHA);
    // Enable blending
    glEnable(GL_BLEND);
    - (void)drawView
    [EAGLContext setCurrentContext:context];
    glBindFramebufferOES(GLFRAMEBUFFEROES, viewFramebuffer);
    glViewport(0, 0, backingWidth, backingHeight);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrthof(-1.0f, 1.0f, -1.5f, 1.5f, -1.0f, 1.0f);
    glMatrixMode(GL_MODELVIEW);
    //Clear the backbuffer
    glClear(GLCOLOR_BUFFERBIT);
    std::list<GameObject*>::iterator Object = (ObjectMgr->mObjectList.begin());
    std::list<GameObject*>::iterator End = (ObjectMgr->mObjectList.end());
    //For each game object
    while(Object != End)
    // Bind the texture name.
    glBindTexture(GLTEXTURE2D, (*Object)->mSpriteTexture);
    //apply transformations
    glPushMatrix();
    glTranslatef((*Object)->mPosition.x, (*Object)->mPosition.y, (*Object)->mPosition.z);
    glRotatef((*Object)->mRotation, 0.0f, 0.0f, 1.0f);
    //(*Object)->mRotation += 0.5f; //Rotate
    //Get current sprites verticies
    glVertexPointer(2, GL_FLOAT, 0, (*Object)->mSpriteVertices);
    glEnableClientState(GLVERTEXARRAY);
    //Get current sprites tex coords
    glTexCoordPointer(2, GL_SHORT, 0, (*Object)->mSpriteTexcoords);
    glEnableClientState(GLTEXTURE_COORDARRAY);
    //Render the vertex array
    glDrawArrays(GLTRIANGLESTRIP, 0, 4);
    //pop the transformation matrix
    glPopMatrix();
    ++Object;
    glBindRenderbufferOES(GLRENDERBUFFEROES, viewRenderbuffer);
    [context presentRenderbuffer:GLRENDERBUFFEROES];

  • Address Book Sync Memory Leak

    Address Book Sync Memory Leak , Using 5.6GB of Real Memory
    Has anyone had issues with this? I have to force quit the process from Activity Monitor every 30 minutes.
    Sampling process 3337 for 3 seconds with 1 millisecond of run time between samples
    Sampling completed, processing symbols...
    Analysis of sampling AddressBookSync (pid 3337) every 1 millisecond
    Process:         AddressBookSync [3337]
    Path:            /System/Library/Frameworks/AddressBook.framework/Versions/A/Resources/AddressBo okSync.app/Contents/MacOS/AddressBookSync
    Load Address:    0x100000000
    Identifier:      AddressBookSync
    Version:         ??? (???)
    Code Type:       X86-64 (Native)
    Parent Process:  SyncServer [3314]
    Date/Time:       2011-05-30 10:09:28.670 -0400
    OS Version:      Mac OS X 10.6.7 (10J869)
    Report Version:  7

    Unfortunately not. No groups and any Mobile Me account here not even many contacts (436) and any duplicates except in Ical after having restored my iphone 4 times. Something strange too, 2 weeks ago, Isync was running while I'm not registered on MM nor Icloud (turned off on my iphone) . Maybe a conflict between Outlook, Addressbook, Itunes and Isync on SL....I'm going crasy with this issue It reminds me of Windows ! Thx anyway, I'm gooing to contact apple in the following days.

  • How to fix huge iTunes memory leak in 64-bit Windows 7?

    iTunes likes to allocate as much as 1.6GB of memory on my dual-quad XEON 8GB 64-Bit Windows computer and then becomes unresponsive.
    This can happen several times a day and has been going on for as long as I can remember.  No other software that I use does this - only Apple's iTunes.  Each version I have installed of iTunes appears to have this same memory leak.  Currently I am running version 10.7.0.21.
    I love iTunes when it works.  But having to constantly kill and relaunch the app throughout the day is bringing me down.
    Searching for a fix for this on the internet just surfaces more and more complaints about this problem - but without a solution.
    Having written shrinkwrapped software for end users as well as for large corporations and governments for more than 25 years I know a thing or two about software.  A leak like this should take no more than a day or two to locate using modern software tools and double that to fix it.  So why with each new version of iTunes does this problem persist?  iTunes for Windows is the flagship software product Apple makes for non-Mac users - yet they continue to pass up each opportunity they have had over the years with each new release to fix this issue.  Why is this?
    Either the software engineers are not that good or they have been told NOT to spend time on this issue.  I personally believe that the engineers at Apple are very good, and therefore am left thinking that the latter is more likely the case.  Maybe this is to coax people to purchase a Mac so that they can finally run iTunes without these egregious memory leaks.  I would like to offer another issue to consider.
    Just as Amazon sold Kindles and Google sold Nexus tablets at low cost - not counting on margin for profit - but instead they wanted to saturate the marketplace with tools for making future purchases of content almost trivial to do with their devices.  Apple also counts on this model with their pricer hardware - but they also have iTunes.  Instead of trying to get people to switch to a MAC by continuing to avoid fixing this glaring issue in iTunes for Windows I would like to suggest that by allowing their engineers to address this issue that Apple will help keep Windows users from jumping ship to another music app.  The profit to be made by keeping those Windows users happy and wedded to the iTunes store is obvious.
    By continuing to keep this leak in iTunes for Windows all it does is lower my esteem for the company and start to make me wonder if the software is just as buggy on Macs.

    I have same issue. Ongoing for more than 1 year and currently running iTunes 11.3.
    My PC is Dell OptiPlex 990 I7 processor, 8GB ram, W7 64 [always keep things patched up to latest OS updates etc]
    I use this iTunes install to stream music videos etc to multiple appleTVs, ipads, iphones etc .. via Home Sharing
    Store all my media including music, videos and apps on separate NAS  .. so the iTunes running on PC is only doing the traffic cop role and streaming / using files stored on NAS .. creates lots of IO across my network
    Previous troubleshooting suggest possible contributing causes include
    a) podcast updates  .. until recently I had this auto updates on multiple podcast subscriptions, presumably the iTunes would flow this from the PC to save on the NAS across the network .. if the memory leak is in the iTunes network communication layer (?bonjour?)  this may be sensitive to IO that would not normally occur if the iTunes file saving was local on the same PC
    b) app updates .. have 200+ apps in my library and there is always a batch of updates .. some updates 100s of MB is size .. routinely see 500MB to 1GB of updates in single update run .. all my apps are
    c) streaming music / movies .. seems when we ramp up streamlining of music or movies . memory leak grows faster .. ie within hours of clean start
    c) large syncs of music or videos to ipads or iphones .. noticed that get big problems when I rebuild an ipad .. I typically have 60+ GB of data in terms of apps /  music / videos to load .. have to do rebuild in phases due to periodic lockups

  • Memory leak in AudioServicesCreateSystemSoundID with sound files

    hi !
    Instruments indicates a 64Ko memory leak in "AudioServicesCreateSystemSoundID" when I use a sound that I have created with GBand / iTunes. When I use the sound file "tap.aif" from the "sysSound" sample, there is no memory leak.
    What's wrong with my audio file ?
    It's a AIFF file, 95Ko, 8 bit mono 22Khz @ 176kbps.
    thanks...

    appFile = [ [ NSBundle mainBundle ] pathForResource : _filename ofType : _extension ];
    FileUrl = [ NSURL fileURLWithPath: appFile ];
    if ( AudioServicesCreateSystemSoundID( ( CFURLRef ) FileUrl, &soundID ) != kAudioServicesNoError )
    return false;
    I don't think the code is wrong because when I change the name of the sound in '_filename', there is no leak.
    I haven't found in the documentation the audio file properties ( 8/16 bits, ... ) supported by 'AudioServicesCreateSystemSoundID'.
    The code is for iPhone.

  • Are you guys going to fix the memory leak in version 6

    Hi I was wondering if you guys were going to fix the huge memory leak in Firefox 6. As of now I use windows Vista 32bit Ultimate and Firefox is using 164MB of memory to view www.google.com. I'm sorta confused also on how SLOW the browser is. I never seen F.F act this way since F.F 6. I'm hoping that this will be resolved in version 7 cuz this is not cool so slow in all.

    On the "flip-side", I had the smoothest and quickest iTunes upgrade/install ever.  This was on my Windows 7 Professional, 64bit system.
    That you performed an assumedly 'clean' reinstall of your OS, is not a good sign.  Obviously, iTunes doesn't like something within your system.
    Here are the next steps that I would take if in your position:
    -  Are you absolutely positive that you have the 64bit version of iTunes?
    -  Re-download a new copy of the 64bit version of iTunes 10.5
    -  Try downloading iTunes from one of the 'mirror sites' - FileHippo is good
    -  Call your PC's manufacturer and see if they are aware of any conflicts with your specific machine's build with respect to iTunes
    -  Temporarily use another PC (if available) to get your iPhones up and running
    Best of Luck

  • Memory leak in NSUserDefaults

    Hi, I have a iphone photography App. In my app, user may open many images. Each time user opens a new image, I will save the image to NSUserDefault so that next time user starts my app, the last image will be loaded.
    Here is my code, (I call this method everytime user opens a new image)
    -(void) saveDefaults:(
    NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
    if (standardUserDefaults){
    NSData* imageData = [NSData dataWithBytes:(void*)someMemoryBuffer length:lengthOffBuffer];
    [standardUserDefaults setObject:imageData forKey:@"MyImage"];
    I do not call [standardUserDefaults synchronize] each time I put a new image in NSUserDefaults. I call it to commit saving image to NSUserDefault only when my program ends.
    It seems that there is a memory leak. I used PerfermanceTool, it does report any memory leak, but I can see that the memory token by my App increases everytime I call "saveDefaults" and perfermanceTool points the increase of memory to the "saveDefauts" function. Is there any memory problem in my code.
    Thank you very much.
    ff

    As I have neither an iPhone Developer account nor an iPhone, I can't help very much. Try this link. I don't know if it will help because I can't sign in. You could save your data in SQLite.
    You could follow these instructions. Try looking at the official Apple documentation instead.

  • NIB Resource Memory Leak

    I have a question: I have an application that uses lots of views and I tend to load them with NIBs:
    MemoryManagementTestViewController *
    newViewController = [[MemoryManagementTestViewController alloc] initWithNibName:@"MemoryManagementTestView" bundle:nil];
    [self.navController pushViewController:newViewController animated:YES];
    [newViewController release];
    After I pop the above view controller off the navigation stack, its viewDidUnload() and dealloc() methods are called (below for a test view controller I created to try to isolate the cause of the problem).
    The Object Allocation instrument tool shows that a number of control initWithCoder methods (such as UITextField initWithCoder) are consuming memory.
    I realize that I am not using the recommended coding style for outlets (my 10 test labels and 10 test text fields), but I have tried to the recommended property style as well.
    I cannot think of anything that I am not freeing, but the combination of the code above and below results in a persistent leak, at least according to the object allocator instrument application (though not with the memory leaks tool). Eventually the application runs out of memory as didReceiveMemoryWarning() is called.
    I looked at your sample source code, and it appears that most of your sample applications load their views at startup instead of creating and freeing them as I am attempting to do. Is that necessary? If not, is there some trick to free NIB resources?
    - (void)viewDidUnload
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
    [label1 release];
    [label2 release];
    // ... labels 3-10 released too.
    label1 = nil;
    label2 = nil;
    // ... labels 3-10 set to nil.
    [text1 release];
    [text2 release];
    // text fields 3-10 released too.
    text1 = nil;
    text2 = nil;
    // text fields 3-10 set to nil.
    return;
    - (void)dealloc
    self.navigationItem.leftBarButtonItem = nil;
    [self setView:nil];
    [super dealloc];
    return;
    }

    secretagentstuart wrote:
    looked at your sample source code, and it appears that most of your sample applications load their views at startup instead of creating and freeing them as I am attempting to do.
    Would those be 'Beginning iPhone Development' samples, by any chance?

  • Can I locate "memory leaks" to keep apps from crashing?

    Hello clever people,
    Since the iPhone 4s is still on the market, I assume that my 2 year old 4s should be able to work fine. However, I am constantly plagued by apps crashing and, most frustratingly, apps often fail to remain running in the background, even with one or no other apps running.
    I had a similar issue with my iPad2, just before it ran out of applecare, and the chap had me run through with sending anaylitcs to him, and his conclusion was that a few apps were causing 'memory leaks' - had me reset the iPad and reinstall everything. So I also did this on the iPhone, which did help, but it has not solved the issue. I have also removed most apps from the device, in a bid to locate the offending app.
    Searching on Google for "memory leak" only brings up info for developers, and nothing for someone who is actually using their phone and having issues. My usual scenario is going for a bike ride and running Strava, which then cuts out when I stop to take a picture - with no other apps running.
    Does anyone know how to solve the issue - return the phone to its 'as new' state, or locate the problem and remove it?
    Cheers,
    Tobias

    There are differenty types of, "resets" ..
    Have you tried the folloiwng ??
    Reset the device:
    Press and hold the Sleep/Wake button and the Home button together for at least ten seconds, until the Apple logo appears.
    If that doesn't help, tap Settings > General > Reset > Reset All Settings
    No data is lost due to a reset.
    Use iTunes to restore your iOS device to factory settings

  • How to determine memory leaks?

    I tried in XCODE, the RUN/ Start with Performance TOol / and tried out the various options. I was running my app and looking to see if it would report increasing memory use but it seemed to be looking at my total system (i was running under the simulator). In general what is the recommended procedure for determining memory leaks, which tool to use, and what tracing can i use?
    How does one look at the retain count of an object? are there system routines that have knonw leaks?

    You took the right path. Once instruments comes up select the Leaks tool. Turn off automatic leak detection. In your app, start off at some known state, do something, and come back to the known state and check for leaks. For instance start off in a view, do something that brings up another view then come back to the original view and check for leaks. Leaks will show you if you leaked. Since you took a very deterministic path then checked it should be straight forward to go to the code and find / fix the leaks. Leaks shows you where the code where the leak was generated.

Maybe you are looking for

  • Oracle Job in case of heterogenous services

    I am trying to transfer some data automatically after every 30 min from MS Access to oracle. What I have done is- 1. Created a ODBC connection and DB link using that DSN and now I can access the data from Oracle to MS Access. 2. I have written a stor

  • IPhone 6 Plus screen rotate glitch

    Has anyone noticed that the home screen doesn't rotate and the native mail app doesn't switch to 2 columns IF you have the phone set on the "zoomed" view vs. the standard view? Try it... set your iPhone 6 Plus to zoomed view (Settings > Display & Bri

  • Best resolution format for graphic in script

    Hi Gurus, Can u pls suggest which is the best format to get the best resolution in scripts while adding graphics thru se78...? thank in advance.. Himayan

  • Can't Connect EAS

    Before I log a support case, has anyone else come across this ??????I can retrieve data fine from my cubes, but when I try to log onto EAS (version 7.1 btw), I get the message "could not connect to Administration Server telesto".Keep in mind we have

  • Motion HD export to SD

    When developing an HD project in motion, what is the best way to export to maintain the best quality for SD?