Service development guidelines

Memory management

Any objects created by the API are managed by the API. You do not need to worry about memory. Use methods in your programming language to free memory for other objects.

How to control memory leaks

Forcing a service instance to restart is one way to control memory leaks.

About threads and multithreading

If you are using a service wrapper to execute UNIX commands and return results to the client, note that the service wrapper is implemented with fork/exec in the onInvoke() call. The onInvoke() call and other calls in Symphony are executed in a thread.

The fork/exec in a multithread environment causes race conditions that could result in deadlock. To resolve this, include -lpthread in the makefile so that the service uses the thread-aware fork in the pthread library instead of fork in glibc. If you are using a Makefile, change it to include the following:
LIBS = -L $(OUTPUT) -L $(TOP)/$(ARCH_BUILD)/lib \
-lsampleCommon -lsoambase -lsoamapi -lpthread