Reputation: 1747
I'm new to java(C# before) and I do not understand how unmanaged resources are freed.
I create FloatBuffer like this FloatBuffer buffer = FloatBuffer.allocate(length);
How do I free it? There is not free, dispose or remove methods
Upvotes: 2
Views: 1529
Reputation: 5661
de-allocation of a FloatBuffer
is handled the same as most other objects(there is always an exception...).
Once you no longer have a reference to the object, GC does its thing when it feels the time is right.
Upvotes: 1
Reputation: 10093
The Garbage collector takes care of it when no longer needed, i.e. it's not reachable in the current active object graph.
Upvotes: 1
Reputation: 13196
All memory management in java is handled automatically (except in a few instances regarding interfacing with native code).
When there are no more references to your declared FloatBuffer, it will become eligible for garbage collection. Sometime thereafter, the garbage collector will run and deallocate its used memory.
Upvotes: 4