Re: Is there any way lib GuardMalloc can be faster?
Re: Is there any way lib GuardMalloc can be faster?
- Subject: Re: Is there any way lib GuardMalloc can be faster?
- From: Eric Albert <email@hidden>
- Date: Mon, 30 Jan 2006 21:16:27 -0800
On Jan 30, 2006, at 9:03 PM, email@hidden wrote:
I'm wondering exactly why is it so slow. I heard .NET with managed
code also has bounds checking etc too. It doesn't seem as slow as
GuardMalloc. Is there a specific reason its faster?
Just wondering, because its excruciatingly slow to debug in this mode,
almost ridiculous. (no offense intended)
Java also has bounds checking and runs much faster than Guard Malloc.
That's because those languages control what you can do in the language
in the first place, so they can know that your object at 0x54341510 is
an array of 12 integers, and that when you execute an instruction which
indexes into the array the index has to be between 0 and 11. C doesn't
work that way. There's no runtime environment to figure out what your
types are. Everything's just memory addresses and data. There's also
no runtime environment to preflight each instruction. Instructions get
sent straight through to the hardware.
Since Guard Malloc doesn't have any easy way to check types or
instructions, it has to use a sledgehammer. It does that by ensuring
that every allocation is on a separate page, typically at the end of
the page with a guard page after it. (You can switch that around with
an environment variable.) That's not only slow, but it uses tons of
memory. The more RAM your system has, the faster Guard Malloc will
run. And the faster a computer you have, the faster it'll run. I find
that an Intel iMac with lots of memory works really well for this.
Hope this helps a bit,
Eric
_______________________________________________
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