Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Java binding NetworkAdapter object leakage
31-01-2014, 06:59 AM (This post was last modified: 31-01-2014 08:48 AM by simoncn.)
Post: #1
Java binding NetworkAdapter object leakage
If a Java application calls Library.getCurrentSubnet(), the returned NetworkAdapter object is shown as a leaked object when the ohNet stack terminates. This is because the native method OhNetCurrentSubnetAdapter() adds a reference to the returned native NetworkAdapter object and there is no API call in the Java binding to remove this reference.

To fix this, a new Java API call NetworkAdapter.removeRef() is required. I am attaching a patch to add this API call. I've tested this and confirmed that it solves the problem with leaked objects.


Attached File(s)
.zip  removeref.zip (Size: 2.57 KB / Downloads: 4)
Find all posts by this user
31-01-2014, 09:50 AM
Post: #2
RE: Java binding NetworkAdapter object leakage
Thanks for finding / fixing this. I've applied your patch so the changes should be available on github this evening.
Find all posts by this user
03-02-2014, 09:39 AM
Post: #3
RE: Java binding NetworkAdapter object leakage
(31-01-2014 09:50 AM)simonc Wrote:  Thanks for finding / fixing this. I've applied your patch so the changes should be available on github this evening.

Thanks very much! I've downloaded and built the new tag, and everything is working well.
Find all posts by this user
03-02-2014, 01:22 PM
Post: #4
RE: Java binding NetworkAdapter object leakage
Hi this is my first day in this forum . if i am doing any thing wrong here correct me .. kindly help me ... its very urgent

i dont have much time to go through all the document .. i will do this later
Can you please let me how to ohNet lib in android ...
Please please ....



Thank you very much reading my query !"!!
Find all posts by this user
03-02-2014, 01:50 PM
Post: #5
RE: Java binding NetworkAdapter object leakage
(03-02-2014 01:22 PM)janamsdn Wrote:  Hi this is my first day in this forum .
Welcome to the forum.

(03-02-2014 01:22 PM)janamsdn Wrote:  if i am doing any thing wrong here correct me .. kindly help me ... its very urgent
Since you asked... It would be preferable to post a new question as a new thread. It gets confusing if a single thread has multiple, independent issues to track.

(03-02-2014 01:22 PM)janamsdn Wrote:  i dont have much time to go through all the document .. i will do this later
Can you please let me how to ohNet lib in android ...
Please please ....

Thank you very much reading my query !"!!
You haven't said what you're trying to do.

If you want to build the library, you can just run

make ohNetAndroidNative ohNetJavaAll

from the command line. Note that some small additions to ohNet/Makefile may be required if you want to do this from a Linux or Mac host. (See the definition of android_ndk_debug in ohNet/OhNet.mak).

Alternatively, you could use pre-built binaries from http://www.openhome.org/releases/artifacts/ohNet/ohNet-[version]-Android-anycpu-[variant].tar.gz.

If you were asking about how to use the library, you'll need to provide much more context (what you're trying to do).
Find all posts by this user
03-02-2014, 02:26 PM (This post was last modified: 03-02-2014 02:44 PM by janamsdn.)
Post: #6
RE: Java binding NetworkAdapter object leakage
Thank you very much
Find all posts by this user
03-02-2014, 02:50 PM
Post: #7
RE: Java binding NetworkAdapter object leakage
(03-02-2014 02:26 PM)janamsdn Wrote:  Apologies for my last post ..
Thank you very much quick response

I am planing to do - Asynchronously discover near by devices through android app ( // Search asynchronously for all devices)
yes i downloaded built binaries from http://www.openhome.org/releases/artifacts/ohNet/ohNet-[version]-Android-anycpu-[variant].tar.gz.
but here m getting confusion is which files i need to import ??Could you please help me



Thank you very much

To use ohNet in an Android project, both the Java library and pre-compiled native ohNet libraries are required.

In the pre-built binaries, these can components can be found at the following locations:
Code:
ohNet-Android-anycpu-Release\lib\armeabi
ohNet-Android-anycpu-Release\lib\armeabi-v7a
ohNet-Android-anycpu-Release\lib\x86
ohNet-Android-anycpu-Release\lib\ohnet.jar

I'll assume you're using Eclipse with the ADT plugin. Copy the 3 directories and Java library listed above into the libs/ folder of your Android project within Eclipse.

You should then be able to include components from the Java bindings in your Android project.
Find all posts by this user
03-02-2014, 04:11 PM (This post was last modified: 03-02-2014 05:10 PM by janamsdn.)
Post: #8
RE: Java binding NetworkAdapter object leakage
yes you right using Eclipse .
then i try to call ohnet lib ---- following line geting Fatal null exception lib.initialise(initParams);
could you please help me following code any thing wrong


InitParams initParams = new InitParams();
Library lib = new Library();
lib.initialise(initParams);
SubnetList subnetList = new SubnetList();
NetworkAdapter nif = subnetList.getSubnet(0);
Inet4Address subnet = nif.getSubnet();
subnetList.destroy();
lib.startCp(subnet);

After setting following InitParams still m geting Fatal null exception ..
InitParams initParams = new InitParams();
initParams.setMsearchTimeSecs(1);// MsearchTimeSecs = 1,
initParams.setUseLoopbackNetworkAdapter(); //UseLoopbackNetworkAdapter = true,
initParams.setDvServerPort(0);//DvUpnpWebServerPort = 0

Thanks for help ..
but i try to make a call to lib still am facing some issues .

//CpDeviceListUpnpServiceType list = new CpDeviceListUpnpServiceType("upnp.org", "ConnectionManager", 1, this);
CpDeviceListUpnpServiceType list = new CpDeviceListUpnpServiceType("urn:schemas-csr-org:service:Tropos:1", "ConnectionManager", 1, this);
Semaphore sem = new Semaphore(1);
sem.acquireUninterruptibly();
try {
sem.tryAcquire(aMsearchTimeSecs * 1000, TimeUnit.MILLISECONDS);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
its not executing following line and not responding
/CpDeviceListUpnpServiceType list = new CpDeviceListUpnpServiceType("upnp.org", "ConnectionManager", 1, this);
CpDeviceListUpnpServiceType list = new CpDeviceListUpnpServiceType("urn:schemas-csr-org:service:Tropos:1", "ConnectionManager", 1, this);
Find all posts by this user


Forum Jump: