[SOLVED] CloudShell2_lcd memory usage

Post Reply
y2i
Posts: 22
Joined: Sat Feb 23, 2019 10:55 am
languages_spoken: english
ODROIDs: XU4
Has thanked: 3 times
Been thanked: 2 times
Contact:

[SOLVED] CloudShell2_lcd memory usage

Unread post by y2i » Mon Jul 15, 2019 6:09 pm

I noticed that after running for a while, CloudShell2_lcd keeps accumulating memory. In my case it was consuming almost 28% of all memory. After system reboot the memory usage by CloudShell2_lcd dropped to 0.3%. Is it possible to look into this? The version I'm running is from early April 2019, may be it was resolved in the recent versions?
Attachments
CloudSHell2Memory.png
CloudSHell2Memory.png (162.57 KiB) Viewed 974 times

joshua.yang
Posts: 287
Joined: Fri Sep 22, 2017 5:54 pm
languages_spoken: Korean, English
ODROIDs: XU4, XU4Q + Cloudshell2, H2, N2
Has thanked: 2 times
Been thanked: 41 times
Contact:

Re: CloudShell2_lcd memory usage

Unread post by joshua.yang » Mon Jul 15, 2019 6:23 pm

We're providing cloudshell-lcd script, and it seems this doesn't cause that problem on our test server. This server runs about 45 days so far.

Screenshot from 2019-07-15 18-30-38.png
Screenshot from 2019-07-15 18-30-38.png (236.95 KiB) Viewed 960 times
How did you install CloudShell2_lcd script? :shock:
Could you install the new script as following this Wiki page? https://wiki.odroid.com/accessory/add-o ... cd_and_fan

And just to ensure, what's your OS and kernel version?

y2i
Posts: 22
Joined: Sat Feb 23, 2019 10:55 am
languages_spoken: english
ODROIDs: XU4
Has thanked: 3 times
Been thanked: 2 times
Contact:

Re: CloudShell2_lcd memory usage

Unread post by y2i » Mon Jul 15, 2019 6:34 pm

Sorry for the confusion, this is not a script. I'm using LCD Display Info and Monitoring Tool viewtopic.php?f=147&t=33860, which comes with /usr/local/bin/CloudShell2_lcd ELF 32-bit executable.

Linux odroid 4.14.107-157 #1 SMP PREEMPT Thu Mar 21 09:59:50 -03 2019 armv7l armv7l armv7l GNU/Linux

y2i
Posts: 22
Joined: Sat Feb 23, 2019 10:55 am
languages_spoken: english
ODROIDs: XU4
Has thanked: 3 times
Been thanked: 2 times
Contact:

Re: CloudShell2_lcd memory usage

Unread post by y2i » Mon Jul 15, 2019 6:55 pm

I just upgraded to the latest cloudshell2-monitoring_1.0.12-1_armhf.deb. It comes with /usr/bin/cloudshell2-monitoring instead of /usr/local/bin/CloudShell2_lcd. I'll update this thread if I continue running into memory issues.

paramedic233
Posts: 62
Joined: Tue May 01, 2018 4:47 am
languages_spoken: english
ODROIDs: XU4Q, Cloudshell2
Has thanked: 2 times
Been thanked: 1 time
Contact:

Re: CloudShell2_lcd memory usage

Unread post by paramedic233 » Tue Jul 16, 2019 2:22 am

Yes, please keep us posted. I noticed that as well.
My unit is back at Ameridroid getting the usb3 connector repaired, so once it is back home I plan on placing it back online.

User avatar
AreaScout
Posts: 1094
Joined: Sun Jul 07, 2013 3:05 am
languages_spoken: german, english
ODROIDs: X2, U3, XU3, C2, HiFi Shield, XU4, XU4Q,
N1, Go, VU5A, Show2, CloudShell2,
H2, N2, VU7A, VuShell
Has thanked: 20 times
Been thanked: 61 times
Contact:

Re: CloudShell2_lcd memory usage

Unread post by AreaScout » Tue Jul 16, 2019 3:20 am

    Uhh, yes there is a memory leak somewhere ... I have to check, at least it looks like

    y2i
    Posts: 22
    Joined: Sat Feb 23, 2019 10:55 am
    languages_spoken: english
    ODROIDs: XU4
    Has thanked: 3 times
    Been thanked: 2 times
    Contact:

    Re: CloudShell2_lcd memory usage

    Unread post by y2i » Tue Jul 16, 2019 12:04 pm

    An update: the new /usr/bin/cloudshell2-monitoring still accumulates memory. After 35 hours the memory usage became 6.6%. After sudo service cloudshell2-monitoring restart the memory usage went back to 0.3%.
    Attachments
    cloudshell2-mon-memory.png
    cloudshell2-mon-memory.png (170.63 KiB) Viewed 850 times

    User avatar
    AreaScout
    Posts: 1094
    Joined: Sun Jul 07, 2013 3:05 am
    languages_spoken: german, english
    ODROIDs: X2, U3, XU3, C2, HiFi Shield, XU4, XU4Q,
    N1, Go, VU5A, Show2, CloudShell2,
    H2, N2, VU7A, VuShell
    Has thanked: 20 times
    Been thanked: 61 times
    Contact:

    Re: CloudShell2_lcd memory usage

    Unread post by AreaScout » Tue Jul 16, 2019 5:31 pm

      It looks like that this code snipped to obtain IP address is the root cause of the memory leak

      Code: Select all

      	struct ifaddrs *ifa;
      	int str_cnt;
      
      	getifaddrs(&ifa);
      
      	while (ifa)  {
      		if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET) {
      			struct sockaddr_in *pAddr = (struct sockaddr_in *)ifa->ifa_addr;
      
      			if (strncmp(ifa->ifa_name, netif, 3) == 0) {
      				str_cnt = sprintf(buf, "%s", inet_ntoa(pAddr->sin_addr));
      			}
      		}
      		ifa = ifa->ifa_next;
      	}
      	freeifaddrs(ifa);
      
      this is what valgrind reports:

      Code: Select all

      ==938== 194,016 bytes in 172 blocks are definitely lost in loss record 71 of 71
      ==938==    at 0x4840C5C: calloc (vg_replace_malloc.c:711)
      ==938==    by 0x4A49911: getifaddrs_internal (ifaddrs.c:411)
      ==938==    by 0x4A4A021: getifaddrs (ifaddrs.c:831)
      ==938==    by 0x12E89B: get_ip(char*) (cloudShell2_lcd.cpp:238)
      ==938==    by 0x12F64B: readSensors() (cloudShell2_lcd.cpp:396)
      ==938==    by 0x133E33: main (cloudShell2_lcd.cpp:1130)
      
      So it seems that this is a bug in libc or where ever those functions are located and I can't remember my tool having a memory leak when I have checked it, so this must be new, maybe freeifaddrs does not free ?

      I will search for a work around, thanks for reporting

      RG

      User avatar
      AreaScout
      Posts: 1094
      Joined: Sun Jul 07, 2013 3:05 am
      languages_spoken: german, english
      ODROIDs: X2, U3, XU3, C2, HiFi Shield, XU4, XU4Q,
      N1, Go, VU5A, Show2, CloudShell2,
      H2, N2, VU7A, VuShell
      Has thanked: 20 times
      Been thanked: 61 times
      Contact:

      Re: CloudShell2_lcd memory usage

      Unread post by AreaScout » Tue Jul 16, 2019 6:28 pm

        Ha ! I found it and it's a stupid error not a libc bug, for those programmers between you guys, you know it ;), I have it fixed already and will test in hour or so and then upload a new binary

        RG

        User avatar
        mad_ady
        Posts: 6795
        Joined: Wed Jul 15, 2015 5:00 pm
        languages_spoken: english
        ODROIDs: XU4, C1+, C2, N1, H2, N2
        Location: Bucharest, Romania
        Has thanked: 216 times
        Been thanked: 166 times
        Contact:

        Re: CloudShell2_lcd memory usage

        Unread post by mad_ady » Tue Jul 16, 2019 10:57 pm

        Forgive my rusty C skills, but is it freeifaddrs(&ifa);?
        I'm too old for pointers anyway...

        User avatar
        AreaScout
        Posts: 1094
        Joined: Sun Jul 07, 2013 3:05 am
        languages_spoken: german, english
        ODROIDs: X2, U3, XU3, C2, HiFi Shield, XU4, XU4Q,
        N1, Go, VU5A, Show2, CloudShell2,
        H2, N2, VU7A, VuShell
        Has thanked: 20 times
        Been thanked: 61 times
        Contact:

        Re: CloudShell2_lcd memory usage

        Unread post by AreaScout » Tue Jul 16, 2019 11:07 pm

          Close, I have solved it this way:

          Code: Select all

          	
          	struct ifaddrs *ifa, *_ifa;
          	int str_cnt;
          
          	getifaddrs(&ifa);
                  _ifa = ifa;
          	while (ifa)  {
          		if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET) {
          			struct sockaddr_in *pAddr = (struct sockaddr_in *)ifa->ifa_addr;
          
          			if (strncmp(ifa->ifa_name, netif, 3) == 0) {
          				str_cnt = sprintf(buf, "%s", inet_ntoa(pAddr->sin_addr));
          			}
          		}
          		ifa = ifa->ifa_next;
          	}
          	freeifaddrs(_ifa);
          
          With ifa->ifa_next the pointer iterates up until it's NULL, so when freeifaddrs want's to free it, the pointer is NULL, so I have stored it and use the still active memory address to free up

          RG
          These users thanked the author AreaScout for the post (total 2):
          odroid (Wed Jul 17, 2019 9:32 am) • y2i (Sun Jul 21, 2019 9:06 am)

          y2i
          Posts: 22
          Joined: Sat Feb 23, 2019 10:55 am
          languages_spoken: english
          ODROIDs: XU4
          Has thanked: 3 times
          Been thanked: 2 times
          Contact:

          Re: CloudShell2_lcd memory usage

          Unread post by y2i » Sun Jul 21, 2019 9:02 am

          Everything looks great with cloudshell2-monitoring_1.0.13-1_armhf.deb, thank you!
          CloudMonitor.png
          CloudMonitor.png (123.48 KiB) Viewed 697 times
          These users thanked the author y2i for the post:
          AreaScout (Mon Aug 05, 2019 7:07 pm)

          Post Reply

          Return to “CloudShell”

          Who is online

          Users browsing this forum: No registered users and 0 guests