Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java API
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Ron McLeod
paul wheaton
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Himai Minh
Bartenders:
Forum:
Other JSE/JEE APIs
Free memory JNA
Aparna Sree
Greenhorn
Posts: 28
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
How do I free memory of a JNA Structure?
//populate bigStruct SomeBigStructure bigStruct = SomeImpl.setBigStruct(id); System.out.println("BigStruct content before free :"+bigStruct.variable1); System.out.println("Before free :"+bigStruct.size()); //clear bigstruct bigStruct.clear(); System.out.println("BigStruct content after free:"+bigStruct.variable1); System.out.println("After free :"+bigStruct.size());
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
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Please add the following line, after line number 8.
bigStruct = null;
S.D. MADHAN
Not many get the right opportunity !
Aparna Sree
Greenhorn
Posts: 28
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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.
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
OutOfMemory error
Garbage Collection Help!
JNA to call Secur32 InitializeSecurityContext, returns error
Garbage Collector program does not run
arrayList.clear() VERSUS arrayList = new ArrayList()
More...