• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
re: large memory malloc
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: large memory malloc


  • Subject: re: large memory malloc
  • From: George Warner <email@hidden>
  • Date: Fri, 01 Jul 2005 09:32:52 -0700

On Thu, 30 Jun 2005 20:32:58 -0400, "James E. Hopper" <email@hidden>
wrote:

> i have a simple xcode project that does a malloc that for the latest
> data set has grown to just under 3gb.  the malloc is failing (on
> 10.3.9).  since i have 4gb of ram and the docs imply i can access up
> to 4gb space without having to go to 64 bit addressing, i was hoping
> there was something simple i could do to make this work?
>
> docs for ld on linux speak of an option --heap that lets you set the
> max heap size, but this is not available on the os x linker.

The problem is that a lot of those pages of memory are being used by system
libraries and frameworks that are mapped into your address space (because
your application is using them). You can view the mapped pages by using the
"vmmap" command (passing it the PID of your running application):

term> ps auxww | grep iTunes

geolocal 12902   7.0 -1.8   438980  37212  ??  R     9:02AM   1:26.64
/Applications/iTunes.app/Contents/MacOS/iTunes -psn_0_3670017

term> vmmap 12902

Virtual Memory Map of process 12902 (iTunes)
Output report format:  2.0

==== Non-writable regions for process 12902
__PAGEZERO             00000000-00001000 [    4K] ---/--- SM=NUL
/Applications/iTunes.app/Contents/MacOS/iTunes
__TEXT                 00001000-004d6000 [ 4948K] r-x/rwx SM=COW
/Applications/iTunes.app/Contents/MacOS/iTunes
__LINKEDIT             005de000-005f5000 [   92K] r--/rwx SM=COW
/Applications/iTunes.app/Contents/MacOS/iTunes
shared memory          005f6000-005f8000 [    8K] r--/rw- SM=SHM
IOKit                  005fe000-00600000 [    8K] r--/r-- SM=SHM
mapped file             00727000-0073b000 [   80K] r--/rwx SM=COW
/System/Library/CoreServices/CharacterSets/CFUnicodeData-B.mapping
    .
    .
    .
STACK GUARD            f051a000-f051b000 [    4K] ---/rwx SM=NUL
system                 fffec000-fffef000 [   12K] ---/rwx SM=NUL  commpage
[libobjc.A.dylib]
system                 fffef000-ffff0000 [    4K] r-x/rwx SM=PRV  commpage
[libobjc.A.dylib]
system                 ffff8000-ffffa000 [    8K] r--/r-- SM=SHM  commpage
[libSystem.B.dylib]

==== Writable regions for process 12902
__DATA                 004d6000-0058c000 [  728K] rw-/rwx SM=COW
/Applications/iTunes.app/Contents/MacOS/iTunes
__DATA                 0058c000-005de000 [  328K] rw-/rwx SM=PRV
/Applications/iTunes.app/Contents/MacOS/iTunes
MALLOC_LARGE           005f5000-005f6000 [    4K] rw-/rwx SM=PRV
DefaultMallocZone_0x1100000
VM_ALLOCATE ?          005f8000-005f9000 [    4K] rw-/rwx SM=PRV
MALLOC_LARGE           005f9000-005fe000 [   20K] rw-/rwx SM=PRV
DefaultMallocZone_0x1100000
MALLOC_TINY (freed?)   00600000-00705000 [ 1044K] rw-/rwx SM=COW
    .
    .
    .
CoreGraphics           b2a25000-b2de5000 [ 3840K] rw-/rw- SM=SHM
Stack                  f0082000-f0102000 [  512K] rw-/rwx SM=PRV
Stack                  f0103000-f0183000 [  512K] rw-/rwx SM=PRV  thread 1
Stack                  f0184000-f0204000 [  512K] rw-/rwx SM=PRV  thread 2
Stack                  f0286000-f0306000 [  512K] rw-/rwx SM=PRV  thread 3

==== Legend
SM=sharing mode:
        COW=copy_on_write PRV=private NUL=empty ALI=aliased
        SHM=shared ZER=zero_filled S/A=shared_alias

==== Summary for process 12902
ReadOnly portion of Libraries: Total=100464KB resident=53924KB(54%)
swapped_out_or_unallocated=46540KB(46%)
Writable regions: Total=394788KB written=23656KB(6%) resident=41756KB(11%)
swapped_out=0KB(0%) unallocated=353032KB(89%)

REGION TYPE             [ VIRTUAL]
===========             [ =======]
ATS (font support)      [  33784K]
Carbon                  [   2256K]
CoreGraphics            [  14120K]
IOKit                   [ 262812K]
MALLOC                  [  51372K]
STACK GUARD             [     40K]
Stack                   [  12860K]
VM_ALLOCATE ?           [   2612K]
__DATA                  [   4988K]
__IMAGE                 [   1088K]
__LINKEDIT              [  21660K]
__OBJC                  [    988K]
__PAGEZERO              [      4K]
__TEXT                  [  78804K]
mapped file              [  21560K]
shared memory           [  16572K]
system                  [     24K]

So iTunes has about 100 Mbytes of read only libraries mapped, 394 MBytes of
writeable (data) regions. That's almost half a GByte. Note also that these
aren't contiguous such that the largest single contiguous area that's
available for your application to allocate is significantly smaller.
--
Enjoy,
George Warner,
Schizophrenic Optimization Scientist
Apple Developer Technical Support (DTS)


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Xcode 1.5 and Run Log?
  • Next by Date: Cross Project Dependencies and Cleaning
  • Previous by thread: Re: large memory malloc
  • Next by thread: Re: Don't understand this compiler warning
  • Index(es):
    • Date
    • Thread