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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:08:19+00:00 2026-05-12T11:08:19+00:00

i’ve been playing some time with different builds of my application and there seem

  • 0

i’ve been playing some time with different builds of my application and there seem strange things to happen:

my app has a 5mb idle footprint. when uploading a file memory in size of the file is reserved. after the upload the reserved memory should be freed. now there are differences in the builds (gc = garbage collector):

  • 32bit i386 no-GC: all memory is freed instantly.
  • 32bit i386 GC: almost all memory is freed instantly. the rest some time later.
  • 64bit x86_64 no-GC: minimal memory is freed. like 10%
  • 64bit x86_64 GC: no memory at all is freed. the memory stays reserved for hours. (activity mon)

i’m using LLVM with CLANG. i have been running today instruments all the time and was checking for leaks/zombies/etc. and everything seems to be clean. (the app is rather simple.)

is there an explanation for this behavior?


Update:

That’s some weird stuff. I’ve boiled the problem to this:

I load a 20mb file into a NSData and release it. I’m doing this without any garbage collection enabled. The code is:

NSData *bla = [[NSData alloc] initWithContentsOfFile:@"/bigshit"];
[bla release];

When I build for i386 32bit the 20mb are allocated and released. When I switch the build to 64bit x86_64 the release does nothing. The 20mb stay allocated.

upper pic 32bit lower 64 http://kttns.org/zguxn

There is no difference between the two apps except that the upper one is built for 32bit and the lower one 64bit. There is no GC running. (With GC enabled the same problem appears.)


Update 2:

The Same behavior can be observed when I create a new cocoa app from scratch with only the upper code in applicationDidFinishLaunching:. In 64bit mode the memory is not released. i386 works as expected.

The same problem appears with NSString instead of NSData. It also appears when I boot the 64bit kernel. (Holding 64 at startup.)

OS is 10.6.0

  • 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-12T11:08:20+00:00Added an answer on May 12, 2026 at 11:08 am

    First, use Instrument’s Object Graph instrument to verify that the memory is no longer considered to be in use; does not have a retain count or a strong reference somewhere.

    If it is no longer in use, then the memory is sticking around simply because you haven’t hit the threshold at which the collector cares.

    However, this statement:

    64bit x86_64 no-GC: minimal memory is
    freed. like 10%

    Makes me wary. Specifically, if your code is designed to work in non-GC — with retain/release — then either (a) you have a memory leak and, if using CFRetain or some kind of global cache, that might impact GC or (b) you aren’t using the right tools to figure out whether or not you have a memory leak.

    So, how are you determining that you are leaking memory?

    Update; you are using Activity Monitor to monitor the RSIZE/VSIZE of the process. This won’t actually tell you anything useful beyond “is my process growing over time”.

    More likely than not (I haven’t looked at the source), this code:

    NSData *bla = [[NSData alloc] initWithContentsOfFile:@"/bigpoop"];
    

    Will cause the 20MB file to be mmap()‘d in to the process. There isn’t a malloc() style allocation involved at all. Instead, the OS hands 20MB of contiguous address space to your process and maps the file’s contents into it. As you read the contents of the NSData, it’ll page fault in the file as you go.

    When you release bla, the mapping is destroyed. But that doesn’t mean that the VM subsystem is going to reduce your application’s address space by 20MB.

    So, you are burning up a bunch of address space, but not actual memory. Since your process is 64 bits, address space is pretty much an infinite resource and there is very little cost to using addresses, thus the reason why the OS is implemented this way.

    I.e. there is no leak and your app is behaving correctly, GC or no.

    This is a common misconception and, thus, star’d the question.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

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.