× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 2/13/2013 4:26 PM, James H. H. Lampert wrote:
stmt = rs_getStatement(rs);
if (stmt <> *NULL);
stmt_close(stmt);
endif;
DeleteLocalRef(JNIENV_P: rs);
if (stmt <> *NULL);
DeleteLocalRef(JNIENV_P: stmt);
endif;
rs = *NULL;

Would anybody happen to know whether or not it's OK to change the order
of the DeleteLocalRef calls (i.e., do "stmt" before "rs")? This would
allow me to avoid having two identical IF statements, but I fear it
might also create a hidden flaw that might not show up in tests. If I
can help it, I'd rather not send out a product with a memory leak (or
worse)!


It feels to me like it would make more sense to delete the reference to stmt before deleting the ref to rs. But for sure I think you should set rs to *null right after you delete the reference to it, to avoid any potential of using a stale object reference.

I don't think the order matters one way or the other. DeleteLocalRef doesn't tell Java to free the object. It just tells Java that you don't need _your_ reference to the object any more. Java can only free an object when there are no more references to it anywhere, whether in native code or within the Java objects themselves.

By the way, maybe you just didn't show it, but you should be setting stmt to *null too.

I don't see any reason you couldn't code it like this, keeping all the stmt code together.

stmt = rs_getStatement(rs);
if (stmt <> *NULL);
stmt_close(stmt);
DeleteLocalRef(JNIENV_P: stmt);
stmt = *null;
endif;
DeleteLocalRef(JNIENV_P: rs);
rs = *NULL;


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.