• Post Reply Bookmark Topic Watch Topic
  • New Topic

Free memory JNA  RSS feed

 
Aparna Sree
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I free memory of a JNA Structure?


I still get the content of the bigStruct and size even after bigStruct.clear();
Is this the proper way to free memory?
 
Madhan Sundararajan Devaki
Ranch Hand
Posts: 312
Java MS IE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please add the following line, after line number 8.
 
Aparna Sree
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Madhan for your reply.

We were actually facing a memory leak issue and I couldnt find out a way to free the JNA memory.

Making it null wasn't a great idea because its just making it available for GC. There is no guarantee that it will be garbage collected.

I went through a few links which said the JNA takes care of freeing memory. You do not have to do it explicitly.

http://markmail.org/message/zdn4ah3kdhiqsr4o#query:jna%20freeing%20memory+page:5+mid:qdgdlevoggyghbgk+state:results
http://markmail.org/message/zdn4ah3kdhiqsr4o

Anyhow the issue was not in JNA code it was in native code and we fixed it too JNA works just fine.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!