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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:15:23+00:00 2026-05-15T08:15:23+00:00

NSString* str = [[NSString alloc] initWithString:@0.05]; NSDecimalNumber* num = [[NSDecimalNumber alloc] initWithString:str]; NSLog(@ %@,

  • 0
NSString* str = [[NSString alloc] initWithString:@"0.05"];
NSDecimalNumber* num = [[NSDecimalNumber alloc] initWithString:str];
NSLog(@" %@", num);
[str release];
[num release];

leaks memory

*** __NSAutoreleaseNoPool(): Object 0x707990 of class NSCFString autoreleased with no pool in place - just leaking

Can someone suggest a workaround ?

  • 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-15T08:15:23+00:00Added an answer on May 15, 2026 at 8:15 am

    What others said; wrap your code with an NSAutoreleasePool. An NSAutoreleasePool is actually surprisingly efficient; will incur very little overhead. You don’t want to, say, surround every few lines of code with one, but it is unlikely that they’ll be measurable in normal use.

    Do not try to use Foundation without Autorelease Pools

    Down that path lies madness. Don’t bother. Sure — it is sometimes a good idea to put some effort into minimizing use of pools, but there will be many cases — like this one — where they are unavoidable.

    No, really, I’m not kidding:

    Cocoa always expects there to be an autorelease pool available. If a pool is not available, autoreleased objects do not get released and you leak memory. If you send an autorelease message when a pool is not available, Cocoa logs a suitable error message.


    I have C++ communication library
    written many years ago. It calls back
    every time there is network event
    (sometimes in a newly created thread).
    Your advise had disastrous effect on
    the performance of my application.

    My answer wasn’t advice, it was a very specific description of the exact rules by which the Cocoa frameworks are implemented. That your code worked before was by coincidence. While there is certainly a behavior change, it isn’t a regression for code that is following the rules.

    Arbitrary threading like that is exceedingly risky within Cocoa (well, really, anywhere). I’ve done such integrations a number of times and have generally found the best solution to be to handle the events in one or more queue like mechanisms, depending on concurrency needs. The queues can then take care of periodically dealing with autorelease pools.

    Of course, the truly arbitrary threading you describe would need some mechanism to move the data over to the queue’s thread(s)….

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

Sidebar

Related Questions

Based on the following code, please advise NSString *str= [[NSString alloc] initWithString:@Hello world]; NSLog(@Length:
The problem: NSString *str = [[NSString alloc] initWithString:theList.artist]; NSLog(@%@,str); // Log gives me the
For NSString, we can use NSString *str = [[NSString alloc] initWithString:@hi] NSString *str =
Assume following code, NSString *str=[[NSString alloc] initWithString:@sagar]; [str autorelease]; I have seen many times
NSString *str = [[NSString alloc]init]; str = [str initWithString:@]; This code crashes. If I
NSString *str = [[[[NSString alloc]init]autorelease]autorelease]; str = @hii; NSLog(@%@,str); Can any one help me
The code is here: NSString * str = [[NSString alloc] initWithFormat:@abcdefgh]; void * pbuffer
What I did is int main(int argc, char *argv[]){ NSString *str = [[NSString alloc]
- (NSString *)allocString{ NSString *str = [[NSString alloc] init]; return str; } - (void)viewDidLoad{
I am trying to create a custom object that simply inherits the NSString class

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.