Safari Web Extension memory leak on using messaging API in popup

Hi, I am working on porting chrome extension to safari web extension and when I run the same code in safari it uses much more memory than in chrome. I am using persistent: true for background script in the extension manifest. It seems when I use browser.runtime.onMessage.addListener in popup code it consumes memory every time when the popup is opened and never frees it. I reproduced this issue in extension example in xcode with this code for popup.js:

browser.runtime.onMessage.addListener(() => {});

setTimeout(() => {
 location.reload();
}, 200);

And persistent: true for background in extension manifest.json. When I run Safari and open the extension popup memory consumption in the activity monitor start to grow with time and this memory is not freed after I close the popup. The same code works normally in chrome. How can I fix this issue?

Safari Web Extension memory leak on using messaging API in popup
 
 
Q