The Wiki page memory management design describes a major long term issue with memory management in IoTivity. The Wiki page memory management design II describes the strategies for improving IoTivity's memory management and tactics for implementing those changes.
This article describes a fork of IoTivity that incorporates most of the changes suggested in the second article.
My group is tasked with discovering how small and useful an OIC server can be in the face of highly constrained resources. Memory is not the only constrained resource we are considering, but it is probably the most important. Two types of memory are important: code size and RAM usage.
The fork is currently not public because of the nature of our exploration. While we have made major modifications to the IoTivity code, we have moved fast, so the results are not always pretty. We are not currently willing to share the code, but that can be a subject of discussion.
The fork runs an OIC server and interoperates with IoTivity. All primary server functionality is complete, though not all of it is tested.
Here are several characteristics of the fork unrelated to memory management. (For comparison purposes the current size of the IoTivity RI layer is about 52K bytes.)
I mention these non-memory issues because they are also applicable to many places IoTivity will be targeted, and we want to show what is possible in those cases.
The fork provide the following improvements for memory management:
The code size and number of mallocs are both dramatically reduced in the forked version of the Connnectivity Abstraction (CA) layer. The mallocs are more difficult to reduce in CA because libcoap performs internal mallocs and forces calling code to do more mallocs. This work is ongoing.
Things not done yet in the fork include memory pools and a dedicated error path.
While the fork is intended as an OIC server in a highly constrained environment, I believe much of what was learned by the exercise can be applied to IoTivity. With some additional work, it could be an alternate branch for building OIC servers in general. Or the code could be mined for individual improvements to the IoTivity code base.
At the very least, the fork provides an existence proof that a more robust OIC server can be built and provides hints about how that might be done.
Intel OTC OIC development