how to free memory from the string that has been written to it via stringToUTF8

according to unity document (1) If the string that has been written to memory using stringToUTF8 is a return value, then the il2cpp runtime will take care of freeing the memory. In the case of passing the string (e.g. using dynCall method) how I should get rid of the written string on memory later on.
here is the related part of my jslib plugin code:

      var str = 'something';
      var bufferSize = lengthBytesUTF8(str) + 1;
      var buffer = _malloc(bufferSize);
      stringToUTF8(str, buffer, bufferSize);
      Runtime.dynCall('vi', CallbackMethod, [buffer]); 

I’m pretty sure you don’t have to take care of freeing the memory in C# because of garbage collection.