ubusd_monitor: alloc & free the buffer outside of the loop