Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
user specified malloc() question (overriding system calls)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

user specified malloc() question (overriding system calls)




I have been trying to fix performance issues that I document with some
of my R code (http://www.r-project.org) on OS X
(http://sekhon.berkeley.edu/macosx/).  Thanks to some suggestions by
the Virginia Tech G5 cluster people, I have been playing with
different memory allocators.  Someone has now claimed that simply
using Doug Lea's malloc could correct the performance problem.  I am
having difficulty correctly linking it in.

I have tried to link against Lea's malloc two different ways. I'm a
linux person so I could very well be doing something wrong.  Any
suggestions would be welcome.

I have tried to hack the R source files themselves, but this  is
leading to some instability.  There should be an easier way. so:

Link in Lea's malloc after a standard build of R on OS X:

This is done by:

1)
Obtain Lea's malloc
ftp://gee.cs.oswego.edu/pub/misc/malloc.c

2)

gcc -g -O2 -o Rlea malloc.c R-2.3.0/src/main/Rmain.c -L/Library/Frameworks/R.framework/Resources/lib/i386 -lR

3)
sudo cp Rlea /Library/Frameworks/R.framework/Resources/bin/exec/i386/
symbolic link R to Rlea

I do not get the speed and I observe some stability issues. I do get
the following warnings (which I don't get on Linux if I do the
equivalent).  But as far as I can tell from online searches they are
to be expected, but I'm suspicious.  So, is the wrong malloc being
used despite of what I think the debugger is telling me is going on?

trin:work/R% gcc -O3 -o Rlea malloc.c R-2.3.0/src/main/Rmain.c
-L/Library/Frameworks/R.framework/Resources/lib/i386 -lR
/usr/bin/ld: warning multiple definitions of symbol _free
/var/tmp//ccJC3VFM.o definition of _free in section (__TEXT,__text)
/usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libSystem.dylib(malloc.So)
definition of _free
/usr/bin/ld: warning multiple definitions of symbol _malloc
/var/tmp//ccJC3VFM.o definition of _malloc in section (__TEXT,__text)
/usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libSystem.dylib(malloc.So)
definition of _malloc
/usr/bin/ld: warning multiple definitions of symbol _realloc
/var/tmp//ccJC3VFM.o definition of _realloc in section (__TEXT,__text)
/usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libSystem.dylib(malloc.So)
definition of _realloc
/usr/bin/ld: warning multiple definitions of symbol _calloc
/var/tmp//ccJC3VFM.o definition of _calloc in section (__TEXT,__text)
/usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libSystem.dylib(malloc.So)
definition of _calloc
/usr/bin/ld: warning multiple definitions of symbol _valloc
/var/tmp//ccJC3VFM.o definition of _valloc in section (__TEXT,__text)
/usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libSystem.dylib(malloc.So)
definition of _valloc

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

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.