Can't find malloc using Arduino Web Editor - fatal error: malloc.h: No such file

I can't compile the MemoryFree example. I end up with "fatal error: malloc.h: No such file or directory".

I don't seem to be able to find any external library to upload to the web editor. I assume malloc.h is a core library include file, but can't seem to find anything about malloc.h and the Arduino Web Editor on the net.

Anyone know what I'm missing here? It works just fine with the Arduino desktop IDE, just not with the web editor.


Post a link to where you downloaded the MemoryFree library from. Please use the chain links icon on the toolbar to make the link clickable.

Also, post the full error output and tell us which board you have selected.

The library was downloaded using the download link on the default library, MemoryFree, using the Arduino Web Editor. It doesn’t provide a link. It just pops up the Windows File Manager to query me on where to save it.

I found it odd that I had to download a default library, MemoryFree, to use it, but followed your instructions to download and then import it, and it solved my original problem of not finding MemoryFree.h. However, now when I use the SEARCH libraries function it now displays 2 versions of the MemoryFree library. Just thought I’d mention it in case it’s relevant.

Here is the error output: (I didn’t include the compiler output that worked. Let me know if you need it)

Using library MemoryFree at version 1.0 in folder: /tmp/155276773/custom/MemoryFree

/tmp/155276773/custom/MemoryFree/src/MemoryFree.cpp:29:20: fatal error: malloc.h: No such file or directory

#include <malloc.h>


compilation terminated.

exit status 1

Since I can’t give you the library’s original URL I uploaded the MemoryFree library to one of my websites.

The problem is that library is part of the Intel Curie hardware package, used for the Arduino 101. Libraries bundled with a hardware package are only accessible when a board of that package is selected. So if you had selected the Arduino 101 (which is part of the Intel Curie hardware package) then it would have worked from the start.

You were able to circumvent that issue by downloading the library from the hardware package and then uploading it back, which installs it outside of the package. This made the library accessible for any board.

However, the file malloc.h is part of the Intel Curie hardware package, it is not part of the hardware package of the board you have selected (I don't know which one because you never answered my question).

Unless you're using an Arduino 101 you're not going to be able to use that MemoryFree library. If you're using one of the Arduino AVR Boards, such as the Uno there is another library of the same name that will work:
GitHub - McNeight/MemoryFree: Arduino MemoryFree library. Hosting it on github for easy access.. To install it:

If you're using a non-AVR board other than Arduino 101 there may be an equivalent library you can use.

Sorry about not telling you which board.

You're right I am using an AVR board and the MemoryFree library link you provided does work with it.

Thank you for your insights and taking the time to answer my questions.

Dynamic allocation on AVR's is not a good idea.

Good catch! I have no plans on using it though. I was testing out the Arduino Web Editor for the first time and just happen to pick that file to compile.

I use an I2C EEPROM for memory operations to limit the writes to my AVR.

You could also use SD or host PC if connected.

But for come and go data I prefer to set up a buffer then use/reuse that space rather than shotgun my heap.