3 ms·
I suggest never to call the garbage collector with the expectation that anything in particular will happen--not in CLR and not in the JVM. Also, do not use fin
by sk5t 11y ago
I suggest never to call the garbage collector with the expectation that anything in particular will happen--not in CLR and not in the JVM. Also, do not use finalizers for this!
JNI and P/Invoke are not really that different except that P/Invoke is a lot easier to implement. But CLR does not know how to cleanup unmanaged resources automagically.
edit: I removed my notes about "try with resource" and AutoCloseable
- pavanky 11y agoWell the only solution remaining is writing C like code, where users have to allocate and free memory manually which is not a solution if you ask me.
- kinghajj 11y agoMay I interest you in Rust? https://www.rust-lang.org/ https://www.rust-lang.org/
- pavanky 11y agoWe already have a wrapper for rust[1] and C++, fortran, python and various other languages[2]. I was talking about people not wanting to move away from their language of choice which results in us having to try and support them as well. [1] https://github.com/arrayfire/arrayfire-rust https://github.com/arrayfire/arrayfire-rust [2] https://github.com/arrayfire https://github.com/arrayfire
- sk5t 11y agoThe trick is to write a managed wrapper that takes care of the housekeeping with AutoCloseable / IDisposable, exception flow control, etc. Careful use of arrays, nonboxed types, and statics instead of beating up the heap space... it can be tedious but someone's got to do the dirty work.