PhilipsHue / HueSDK

Philips Hue Software Development Kit
98 stars 39 forks source link

Memory is continuously going up at bridge search #28

Closed hirokuni closed 6 years ago

hirokuni commented 6 years ago

Hi

There is a possibility that search thread has memory leak. I could not check in the code since it could be in native code. When I called startBridgeDiscovery() in HueQuickStartAppAndroid continuously like following patch , I realized that memory consumption (VSIZE and RSS ) seems to be going up. (I checked it with adb shell ps | grep "philips" x 7 times).

patch

diff --git a/HueQuickStartApps/HueQuickStartAppAndroid/app/src/main/java/com/philips/lighting/hue/demo/huequickstartapp/MainActivity.java b/HueQuickStartApps/HueQuickStartAppAndroid/app/src/main/java/com/philips/lighting/hue/demo/huequickstartapp/MainActivity.java
index a5f6817..05d8e69 100644
--- a/HueQuickStartApps/HueQuickStartAppAndroid/app/src/main/java/com/philips/lighting/hue/demo/huequickstartapp/MainActivity.java
+++ b/HueQuickStartApps/HueQuickStartAppAndroid/app/src/main/java/com/philips/lighting/hue/demo/huequickstartapp/MainActivity.java
@@ -142,6 +142,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
             // Set to null to prevent stopBridgeDiscovery from stopping it
             bridgeDiscovery = null;

+            Log.i("MainActivity", "start search again");
+            startBridgeDiscovery();
+
             runOnUiThread(new Runnable() {
                 @Override
                 public void run() {

Memory status

USER      PID   PPID  VSIZE  RSS   WCHAN              PC  NAME

u0_a27    16759 895   1652244 73848 SyS_epoll_ 0000000000 S com.philips.lighting.hue.demo.huequickstartapp
u0_a27    16759 895   1655560 74200 SyS_epoll_ 0000000000 S com.philips.lighting.hue.demo.huequickstartapp
u0_a27    16759 895   1657340 74684 SyS_epoll_ 0000000000 S com.philips.lighting.hue.demo.huequickstartapp
u0_a27    16759 895   1658352 74700 SyS_epoll_ 0000000000 S com.philips.lighting.hue.demo.huequickstartapp
u0_a27    16759 895   1659672 74864 SyS_epoll_ 0000000000 S com.philips.lighting.hue.demo.huequickstartapp
u0_a27    16759 895   1661696 75504 SyS_epoll_ 0000000000 S com.philips.lighting.hue.demo.huequickstartapp
u0_a27    16759 895   1662708 75796 SyS_epoll_ 0000000000 S com.philips.lighting.hue.demo.huequickstartapp

I would like to continuously keep searching bridge and hue lights without UI trigger around the mobile device. Could you advise me what I should do for it?

jhvdb87 commented 6 years ago

Searching for bridges only makes sense, when you lose connection or when you didn't connect to a bridge yet. I would also advice you to subscribe to our other channel, because we reimplemented the bridge discovery module and also fixed some memory issues. Subscription link: https://developers.meethue.com/content/edk-terms-use