Imagine that you call from a language with GC repetitively a function from another language (e.g., Fortran 95). The Fortran function leaves something allocated in the memory between calls which might be seen from the caller language as unreferenced rubbish.
Could GC from the caller language access the memory allocated in Fortran and consider it as rubish and free it?
I guess that it won't happen. The memory allocated by the Fortran function should have its own memory management separated from the memory managed by GC, however, I would be happy if anyone could confirm that.
Why do I need it? (if anyone is interested)
As described above, I need to write a fucntion in F95 which allocates its own memory, is called several times and it needs to keep the reference to the allocated memory between calls. The problem is that Fortran pointers are incompatibile with the outside world so I can't just pass something as 'void *' from Fortran. Therefore the Fortran function would store the pointer not as a pointer but would cast it (for example) as an integer array for the outside world. However, if GC could anyhow interfere memory from Fortran, it might not understand that the reference is kept in the integer array and might want to free the memory allocated in Fortran, which would be bad.
Thanks for your time. Jan