I’m writing a program that operates on some very big graphs, that in total don’t fit into my computers memory. I process the graph step by step, and sometimes copy it into a new one.
A simple test showed, that rust in release mode only drops values when they go out of scope, in my case at the end of the function.
Is there a good reason for keeping them so long, or is this just for simplicity? They could also be dropped right after their last usage in the function.
I know that I can use drop to free the memory taken by a graph early, but that’s kinda tedious and error prone.
Would there be any downsides to releasing resources that will never be used again immediately after their last usage?