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

  • Home
  • SEARCH
  • 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 3456414
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:44:01+00:00 2026-05-18T09:44:01+00:00

I am somewhat confused about when things are allocated on the heap (and I

  • 0

I am somewhat confused about when things are allocated on the heap (and I need to release them) and when they are allocated on the stack (and I don’t need to relese them).

Is there a rule of thumb?

I think in C++ the rule of thumb is that if you use the new keyword they are on the heap. What is the rule with objective c? How can I tell when something is allocated on the stack?

Will this line of code be allocated on the stack?

NSString *user = @"DEFAULT";
  • 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-18T09:44:01+00:00Added an answer on May 18, 2026 at 9:44 am

    In Objective-C, it’s easy: all objects are allocated on the heap.

    The rule is, if you call a method with alloc or new or copy in the name (or you call retain), you own that object, and you must release it at some point later when you are done with it. There has been plenty written on the subject.

    The example you give is a special case: that’s a static string, I believe it is actually located in the program’s data segment (on the heap), but it’s static so you don’t need to worry about releasing it.

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

Sidebar

Related Questions

I'm somewhat confused about the lifecycle of ManagedBeans of type request. In this example
I am somewhat confused about memory allocation of static variable in objective C. should
I'm somewhat confused by #define statements. In libraries, they seem to be a means
I am somewhat confused, need some C/C++ guru here. If it is C and
I am somewhat confused about how the group by command works in mysql. Suppose
I've come across the page in SQL Server 2008, and is somewhat confused about
I am somewhat confused about presence of two seemingly identical VB.NET functions: CType(args) and
i am studying about views in sql and somewhat confused and having the following
I am somewhat confused about a paragraph in the code complete book. In the
I am learning about SOAP implementation and have become somewhat confused regarding the appropriate

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.