Unallocating direct buffer
I have a direct buffer that I eventually no longer need and set to null.
This however does not free up the memory usage until I perform GC manually.
Is there a way to forcefully free that memory automatically when im setting the buffer to null?
9 Replies
ā
This post has been reserved for your question.
Hey @špothicon! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
no, the gc does as the gc pleases
a direct buffer is just a byte array in the end. you cant deallocate a byte array immediately
the gc will free the memory when it's no longer needed. it's specifically engineered to do that. you dont need to worry about it
if you do want to worry about it, you can just call upon the c standard library to malloc() and free() a pointer and use that to do your stuff (although i dont recommend doing that)
you can call
it like suggests the garbage cleaner to work
but does it as it pleases as mr 0x said
š¤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
the java garbage collector has several levels of storage. the one that takes the most time to clean up is the permanent generation, where the objects that have been active for most time. If you can reduce the time the references to objects are kept (for example instead of reusing a buffer for several operations, create a new buffer for every single operation) those object will not survive long in the ephemeral generation and the memory usage may not be as large at any given instant
with all due respect this advice is ass
allocating and deallocating takes time. if need be for more memory, the gc will free everything it can. if you dont need to allocate and deallocate shit all the time, your program will run faster
yea ig the best choice is to just try to somehow optimize this buffer or just trying to call after ur done
ah so i dont have to worry about it technically having more memory allocated
because it can still use it
š¤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.