The leak seems to be caused by the + operator. I did the following changes, and the problem disappeared:
In unit ui,
change buffer to shortstring
change displayMessage to use shortstring
change bufferMessage to use shortstring
In unit player_inventory,
removeFromInventory function, instead of:
ui.bufferMessage('You drop the '+newItem.itemName);
use:
WriteStr(ss,'You drop the ',newItem.itemName);
ui.bufferMessage(ss);
ss is a local var of shortstring