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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:27:16+00:00 2026-06-13T09:27:16+00:00

My co-worker and I are having a problem we are trying to fix. It

  • 0

My co-worker and I are having a problem we are trying to fix. It has to do with memory allocation. Our code uses loops and componentsSeperateByString to split a large document by the character “\n”. The weird thing is that this never returns all the memory it took. Or at least when we check it doesn’t can someone look at the code below for the function and tell us what we might be doing wrong.

- (void)loadTagmeTest:(NSString *)selectedTargetName
{           
    NSString *path = [[NSBundle mainBundle] pathForResource:selectedTargetName ofType:@"tagme"]; 
    NSString *objData = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];

    NSArray *lines1;
    NSArray *lineVertices1;
    NSArray *lineNormals1;
    NSArray *lineTexcoords1;

    lines1 = [objData componentsSeparatedByString:@"\n"];


    // Iterate through file once to discover how many vertices, normals, and faces there are

    lines1 = [self getList:objData separator:@"\n"]; 


    for (NSString * line in lines1)
    {
        if ([line hasPrefix:@"Verts: "])
        {            

            lineVertices1 = [[line substringFromIndex:7] componentsSeparatedByString:@","];
        }
        else if ([line hasPrefix:@"Normals: "]){

            lineNormals1 = [[line substringFromIndex:9] componentsSeparatedByString:@","];
        }
        else if ([line hasPrefix:@"TexCoords: "]){

            lineTexcoords1 = [[line substringFromIndex:11] componentsSeparatedByString:@","];
        }
    }

}

Edit: This is no longer a pressing matter as we rolled our own version of the parsing function, so now the code uses less memory, actually returns the memory it uses after it is done, and is slightly faster to parse (a whole document (about 10,000 lines) parses and is transormed into floats, put into arrays etc, etc in about 100ms.

Although it is not a pressing concern i would like to know why the memory allocation of NSString is so bad (at least in our implementation above).

Thanks.

  • 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-13T09:27:17+00:00Added an answer on June 13, 2026 at 9:27 am

    I have not found the answer to this question but I have created a work around, that is a bit faster in what I need.
    I use base C code and memcpy to parse my file into what I need bypassing the weird actions of NSString seperate that happen on my devices.

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

Sidebar

Related Questions

I am trying to create a quick fix for a problem I am having.
I'm having a problem where an application I'm working on has memory leaks. Experience
I'm having problem (basically, I'm confused.) while trying to create a worker thread for
I'm having a never-ending problem with trying to call a stored procedure from a
Hi I am having a problem when trying to update a table using an
I'm a designer trying to learn Jquery and I'm having a problem with a
I'm having a problem while trying to dynamically change a table cell's styling class
I am having a problem when i am trying to compare two dates in
I am trying to help a co-worker with a peculiar problem, and she's limited
I am trying to create a login form. The problem that I am having

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.