How to handle malloc fail in application?

how to handle malloc fail in application thread?
im new to develop on openwrt , so hope you could give me some advice!
write log and exit thread, restart the application?