2

I'm using a Raspberry Pi to display information collected from some automated equipment in an industrial environment. The data is collected and stored in a database on an industrial PC; I've got the Pi hooked up to it via a wired network, and I'm using PHP to pull data out of the database and display it.

The issue I'm running in to is with memory. I'm running just a test right now, pulling a table with one record and three columns and displaying it on the web page, and using header("Refresh: 2; URL=$_SERVER['REQUEST_URI']"); to keep the information updated. After getting the Dead Jim page in Chromium a few times, I started keeping track of memory with vmstat to see how quickly it's getting used up. Chromium eats about 5.4 MB a minute, and Midori 4.8 MB per minute.

This is a process that's supposed to run 24/7, rebooting maybe once a week when the industrial equipment goes down for maintenance. What can I do to help out with memory usage? Is there some sort of browser setting to prevent caching anything that might help? Is there a better browser out there that I should be using? I've seen these sorts of issues all over the place in messageboards across the web, so I don't think it's my php code that's doing it, though I'll put it up if anybody thinks that could be the problem.

NickGlowsinDark
  • 337
  • 1
  • 6
  • 17
  • So the browsers never release their memory? – Halcyon May 09 '14 at 19:48
  • I'm not really sure what's going on in there. I use vmstat to watch the memory, and the free memory just ticks down until it hits around 8.2 MB. It then sits there for about five minutes (meanwhile it takes 30 or 40 seconds to refresh my webpage), until suddenly something changes. My swap file (which was around 102 MB) is down to 32 MB, and my free is back up to 178 MB. For the next half hour or so, everything runs fine, until free is back down to 8 MB. Wash, rinse, repeat. – NickGlowsinDark May 15 '14 at 18:41
  • 1
    What if you fetch the updates with ajax instead, do you get the same behaviour? There might be something to those refreshes that causes Chrome to gobble up so much memory. – Halcyon May 15 '14 at 19:26
  • Try disabling JavaScript in Chromium or Midori and see if the problem recurs. Maybe you can do without that in your web site, and that's one less thing the browser will need to reserve memory for. – halfer May 15 '14 at 21:23

2 Answers2

1

It looks like you make the browser refresh the page after fixed time delay no matter if your raspberry ( web server) was able to create a new page and complete the process or not. I also had situations where my browser showed up a blank page by doing similar things. My solution for that was simply to synchronize both. Which means

  1. The browser requests data from your web server
  2. the server creates data and sends it to the browser
  3. The browser waiting for the data updates it's display and delays some time or creates a new request immediately

As far as I know this is a typical scenario and use-case for AJAX.

tswaehn
  • 387
  • 1
  • 11
  • I was really hoping to avoid doing it this way; just trying to keep everything super-simple, since I'm essentially the only programmer in my company who understands any sort of web programming (everyone else has more of a PLC/ladder-logic sort of skill-set) but this was definitely the only way to keep everything from crashing out. After about 20 hours of running it using the XMLHTTPRequest method, I'm at 17% memory remaining, but it looks like it's releasing memory the way it's supposed to now. – NickGlowsinDark Jul 29 '14 at 12:19
  • You may drop me a mail if you need support :-) – tswaehn Jul 30 '14 at 13:55
0

I was running into a similar issue with my raspberry pi using chromium. I am holding a webpage open and having it refresh at various intervals, only the browser was not updating my metrics. After booting with this flag disable the problem was resolved. Consider giving this a try.

In kiosk mode, in auto start I flipped this flag: --disable-gpu-program-cache

You can find more documentation here: http://www.chromium.org/developers/design-documents

John
  • 214
  • 3
  • 14