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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:42:43+00:00 2026-05-27T14:42:43+00:00

I have the following method in my app : – (void) loadModel { //

  • 0

I have the following method in my app :

- (void) loadModel {
// Runs in a seperate thread so we need to create an additional NSAutoreleasePool
pool = [[NSAutoreleasePool alloc] init];

NSData *getData = [activeModelInfo getFileData];

if (getData) {
    if ([activeModel loadFromFileData:daeData]) {
        [activeModel reset];
        [mainViewController performSelectorOnMainThread:@selector(showModelView) withObject:nil waitUntilDone:NO];
    }
    else {

    }
}
else {

}

[pool release];

}

The loadFromFileData method calls the following code which loads data. :

- (void) loadVerticesFromSource:(NSString*)verticesSourceId meshNode:(TBXMLElement*)meshNode intoMesh: (Mesh3D*) mesh {

NSLog(@"Getting Vertices for Source %@",verticesSourceId);

FloatArray *floatArray =  [self getFloatArrayFromSource: verticesSourceId meshNode: meshNode];

if (floatArray) {
[daeFloatArray addObject:floatArray];
}

if (floatArray) {
    if ([floatArray.array count] % 3 != 0) {
        NSLog(@"Float array length not divisible by 3!");
    }
    else {
        mesh->verticesCount = [floatArray.array count] / 3;
        mesh->vertices = malloc(sizeof(Vector3D) * mesh->verticesCount);
        for (int i=0; i<mesh->verticesCount; i++) {
            mesh->vertices[i].x = [[floatArray.array objectAtIndex:(i*3)] floatValue];
            mesh->vertices[i].y = [[floatArray.array objectAtIndex:(i*3)+1] floatValue];
            mesh->vertices[i].z = [[floatArray.array objectAtIndex:(i*3)+2] floatValue];

            // update extents information
            if (!extents.pointDefined || mesh->vertices[i].x < extents.minX) extents.minX = mesh->vertices[i].x;
            else if (!extents.pointDefined || mesh->vertices[i].x > extents.maxX) extents.maxX = mesh->vertices[i].x;
            if (!extents.pointDefined || mesh->vertices[i].y < extents.minY) extents.minY = mesh->vertices[i].y;
            else if (!extents.pointDefined || mesh->vertices[i].y > extents.maxY) extents.maxY = mesh->vertices[i].y;
            if (!extents.pointDefined || mesh->vertices[i].z < extents.minZ) extents.minZ = mesh->vertices[i].z;
            else if (!extents.pointDefined || mesh->vertices[i].z > extents.maxZ) extents.maxZ = mesh->vertices[i].z;
            if (!extents.pointDefined) extents.pointDefined = YES;

            [pointerStorageArray addObject:[NSValue valueWithPointer:mesh->vertices]];
        }
    }
}
}

Since this method is called several times while the data loads, each time mallocing memory for the mesh->vertices struct, I have created a pointerStorage array where I store the pointer to the malloced memory.

The app then displays a 3D object using OpenGL ES. When the user presses a Main Menu button, I then free up the pointerStorageArray as follows :

- (void) freeUpMallocedMemory

for (NSValue * value in pointerStorageArray) {

    free(value);

}

The problem is that the app then crashes during this process. All I get is the EXC_BAD_ACCESSS error message and a pointer to the following line of code in the loadModel method above :

[pool release];

Nothing in the stack trace. I have also tried turning on NSZombie, NSAutoreleaseTrackFreedObjectCheck and NSDebugEnabled, but I still don’t get any additional information.

The odd thing is that if I put a delay on the button of 2 seconds (i.e only trigger the freeUpMallocedMemory method after 2 seconds), the app no longer crashes and works fine.

Can anyone suggest what might be causing this – really confused and have already spent a few days troubleshooting.

Thank you !

  • 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-27T14:42:43+00:00Added an answer on May 27, 2026 at 2:42 pm

    You are over-releasing… the values in pointerStorageArray are created via a convenience method and as such don’t need releasing, simply removing them from the array will dispose of them.

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

Sidebar

Related Questions

I have the following method in a Java app: public void setPixel(int x, int
I have the following method public static void SerializeToXMLFile(Object obj,Type type, string fileName) {
i have the following method in a usercontrol protected override void Render(HtmlTextWriter writer) {
I have the following method in my PyQt4 app. r2 is the number of
I have following simple method in my main activity. private void showMap(String name )
I have one class name as myClassCalculate have the following method - (void) accelerometer:(UIAccelerometer
In my Spring app, I have the following: @RequestMapping(method = RequestMethod.GET, value = /)
In my iPhone app, I have a UITableView with the following method - (NSInteger)numberOfSectionsInTableView:(UITableView
Currently, I have the following method that writes to excel 2007. public static void
In my Rails app, I have the following method: def navigation_menu(items) # raise items.class.to_s

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.