How to profile memory usage of custom written scripts in Zeek 6.0.1

Hello everyone
I was wondering if there is a way to see the memory allocated by my own custom scripts? I want to troubleshoot an unbounded growing state caused by a custom script.

I’ve read the Troubleshooting section explaining how to see memory allocation in real time by using jemalloc, but if i’m not mistaken it can’t help me see how much memory each script allocates as jemalloc only shows cpp functions calls.

I’ve also looked into other tools such as the “–profile-scripts” option (but it shows memory allocated overall at runtime, and doesn’t show what allocated memory was freed )

I also tried loading the “profiling.zeek” script, hoping it will show me all allocated tables and sets sizes and then I could see if there was one that grows too much, but this script looks deprecated and doesn’t print those variables.

Is there any way I can troubleshoot the unbounded growing state caused by my own scripts? (on live traffic)

Thanks in advance!

You can get visibility into the sizes of individual Zeek scripting data structures using the global_container_footprints() built-in. A “footprint” is an approximate notion, not directly corresponding to bytes, but if you make periodic calls to it you should be able to spot meaningful growth. You can also analyze individual values with val_footprint().