Author Topic: Malloc Package Choices  (Read 3022 times)

Offline Holyavenger

  • Friend
  • **
  • Posts: 92
    • View Profile
Malloc Package Choices
« on: January 23, 2011, 06:15:23 am »
With the increased memory stick sizes since 92, why does MudOS/FluffOS choose SYSMALLOC as kind of the default for most libs. Is the CPU  overhead just not worth the stats?

/* You must choose exactly one of these malloc packages:
 *     ~~~~
 * SYSMALLOC:
 *   * Built-in system malloc.
 *   * No statistics.
 *   * SYSMALLOC incurs no additional CPU or memory overhead.
 *
 * SMALLOC:
 *   * Satoria's smalloc.
 *   * Statistics available. (see wrappers and DO_MSTATS)
 *   * Faster than most system mallocs with modest ammount of memory overhead.
 *   * Can fall back onto system malloc if sbrk() not ok.
 *
 * BSDMALLOC:
 *   * BSD (Berkeley Software Distributions) malloc.
 *   * Statistics available. (see wrappers and DO_MSTATS)
 *   * Faster than SMALLOC but more memory overhead.
 *   * Requires sbrk().
 */

Offline Raudhrskal

  • BFF
  • ***
  • Posts: 214
  • The MUD community needs YOUR help!
    • View Profile
Re: Malloc Package Choices
« Reply #1 on: January 23, 2011, 08:10:10 am »
* Raudhrskal makes a wild guess...
Others hasn't been maintained since a decade and Plainly Don't Work Anymore?
* Raudhrskal hides!
I think, therefore i may be wrong.
Please note that if you met a Raudhrskal in a place that's not related to muds, it wasn't me. *sigh*... back when I started there was zero hits on google for that name...

Offline Holyavenger

  • Friend
  • **
  • Posts: 92
    • View Profile
Re: Malloc Package Choices
« Reply #2 on: January 23, 2011, 01:10:00 pm »
* Raudhrskal makes a wild guess...
Others hasn't been maintained since a decade and Plainly Don't Work Anymore?
* Raudhrskal hides!

Probably right.

The wiki says,

"On certain architectures and data models (such as LP64 on 64-bit systems, where long and pointers are 64-bit and int is 32-bit), this error can actually result in undefined behaviour, as the implicitly declared malloc returns a 32-bit value whereas the actually defined function returns a 64-bit value. Depending on calling conventions and memory layout, this may result in stack smashing."

Since they are outdated on 64 bit machines (SMALLOC/BSDMALLOC) is there any reason to leave this as a choice in the driver?




Offline quixadhal

  • BFF
  • ***
  • Posts: 642
    • View Profile
    • WileyMUD
Re: Malloc Package Choices
« Reply #3 on: January 23, 2011, 06:36:33 pm »
Not to mention the fact that the REASON people wrote their own memory allocation routines back in 1990 was the poor performance of the OS versions (I'm looking at you Solaris).  These days, if you're going to go to the effort of using anything other than the system malloc, I'd use gcmalloc.

Offline wodan

  • BFF
  • ***
  • Posts: 434
  • Drink and code, you know you want to!
    • View Profile
Re: Malloc Package Choices
« Reply #4 on: January 24, 2011, 04:31:02 pm »
I think the BSD one is likely a straight copy from the BSDs of the day, I guess that could be removed now, any system malloc should be better, I'll have a look at the current selection.