next up previous
Next: Is there a way Up: Frequently Asked Questions Previous: Does malloc() really never

malloc() never returns NULL, is it a good thing?

Yes and no. Neglecting a return value in C is usually a source of errors, and doing it systematically on malloc() is actually introducing a dependency in your code on this module.

On the other hand, if you really have a need for very large amounts of memory, this module is not going to replace a careful analysis of the hardware you have. You will have to go buy RAM chips or add swap space to your machine. This is not due to the library, but to the fact that you know you are going to need large amounts of memory and should spend the money on the machine in consequence. The VM module is there as a safety net so that the process can run on virtually any machine, it does not replace efficient hardware.

If you have more RAM than you need, this module will actually never create swap files and only be transferring calls to the system's memory functions.


next up previous
Next: Is there a way Up: Frequently Asked Questions Previous: Does malloc() really never
Nicolas Devillard 2002-05-03