1

We are developing an application using the LeapMotion SDK in VS2012 Express for desktop using C#. Therein we add a listener thread to the Leap Controller object. As so:

Controller objcontroller = new Controller();
Listener objlistener = new LeapListener();
objcontroller.AddListener(objlistener);

The controller object does a callback of overridden methods like OnFrame() etc.

The problem is the listener thread exits automatically after certain number of callbacks which range from 3000 to 5500. The output window shows the following text:

The thread (0x1614) has exited with code 0 (0x0).

LeapMotion is a motion detection device which reports frames at a rate of upto 100 fps. When a frame is detected the OnFrame() method gets called.

We tried using try catch.. and no exceptions are thrown - since exit code is 0. I feel the memory consumption is getting exceeded which causes the compiler to shutdown the thread.

Any ideas on this would be helpful.

Platform target is x86 and .net framework target is 4.0

Ondrej Janacek
  • 12,486
  • 14
  • 59
  • 93
Vaibhav
  • 359
  • 3
  • 8
  • 17
  • "I feel the memory consumption is getting exceeded" Out of memory would lead to OutOfMemoryException. Why don't you show the relevant parts of your thread code here? Seems more likely you're not checking errors etc properly and the thread just quits becasue there's nothing more to do. – stijn Sep 06 '13 at 10:06
  • @stijn: The thread is the code contained in OnFrame() method. The method gets called back when a frame is detected. If its not a problem with memory, what can it be....?? – Vaibhav Sep 06 '13 at 10:45
  • "what can it be....??" It could be anything. You haven't shown any code, so we have absolutely *no idea* of how to narrow down the possibilities. – Jim Mischel Sep 06 '13 at 19:12
  • Are you holding a persistent reference to your Controller object(objController)? If not, it will get garbage collected after some in determinant interval, which could explain the behavior you observe. – Charles Ward Oct 07 '13 at 19:22

2 Answers2

1

There is a related question which I answered here: Leap Listener controller stops working after some time in VS2012

Simply put: your controller and listener objects go out of scope and get disposed by the GC.

Community
  • 1
  • 1
Bartosz
  • 732
  • 9
  • 30
0

Its actually a problem with the WPF and Leap code.

In this case I simply reassigned the controller on Exit of the Listener. I declared a Listener object globally in my class as

public static Listener objlistener; 
public static Controller controller;

And add this on the onExit() event

public override void OnExit(Controller controller)
{
          objlistener = new LeapListener();
          controller.AddListener(objlistener);
}
Aditya Alle
  • 57
  • 1
  • 11