Smell of memory leak or bug

Hi everyone.

I wrote two very simple tonic app

  1. server
  2. client and spawn 1_000 client to server ( just call a rpc method (hello word) )

my client app shutdown after 30 seconds

I see my server memory usage by (ubuntu 20, default system monitor)
after spawned all client i see memory grow from 20mb to 203mb

but after my client shutdown in system monitor i saw my server memory usage
is yet 203mb

why after shutdown client ( all worker client connection) not release my memory
in server app??

That sounds normal. The default memory allocator is very happy about holding on to memory rather than giving it back to the OS because doing so is generally faster. However it means that the memory usage does not go back down according to system monitors.

The memory should be reused if you try doing it twice.

1 Like

Thanks for your prompt reply
But this does not cause a out of memory in production ?

Well, pretty much all programs in every OS do something like this, so it must work reasonably well.

very very thank you

You also can use valgrind to make sure no real leak is happening

1 Like

this is first my question in rust community ,

here are very great developer,
quick answer,

im happy and thank

1 Like

I want to add a couple of things:

  • Rust doesnt protect from memory leak, thats why a leak its still a possibility
  • Valgrind used to require you to change the allocator to work correctly, I dont know if this have changed, but I used it recently with the default allocator and it did deetect the leak correctly , so some reasarch might be needed if you're going to use it
1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.