correctly track freed bytes in jl_genericmemory_to_string (#54331)
Master version of https://github.com/JuliaLang/julia/pull/54309.
Should fix https://github.com/JuliaLang/julia/issues/54275.
---------
Co-authored-by: Jameson Nash <vtjnash@gmail.com>