Forums

Measure RAM usage

I understand that there is a 3GB limit - I have exceeded this a couple of time and amended code to prevent recurrence.

But what is the recommended way of profiling memory usage on the webapp, so I can see whether it is often close to the limit or not?

"vmstat -s" could be a choice but the setup reports "Error: /proc must be mounted" and I am not root to run this.

Tks ~Steve

Unfortunately, we do not have a good way for you to monitor your virtual memory use at the moment. I have checked your web app processes and it looks like whatever you did worked. Your virtual memory use is minimal at the moment. However, it could get complicated if there is only one view that causes the memory use to increase.

Hi Glenn

We use mailgun for sending emails and periodically check mailgun logs to get the event status on the sent emails (which returns a json response). The actual offending line of code printed the json response to stderr for debugging purposes - commenting this out has prevented the memory exception. We had just sent a mailshot of 50 emails.

It appears that we cannot monitor memory usage but PythonAnywhere can. If possible maybe you could configure an email alert if we exceed (say) 80% of the 3GB. It would at least give us a chance to review whether the app was regularly approaching a breach, although it would not pre-warn on intermittent memory spikes.

Just a suggestion. Tks for the reply.

~Steve

thanks! will keep your suggestion in mind. on the other hand, it's perhaps a bit weird that printing a json would take 3GB. is that json very big?

I didn't get the length and was more concerned about fixing the immediate fault than investigating. But I will measure it shortly ...

On mailgun when you check logs you can specify how many events should be returned in the JSON data. I have it set at 300 max, so I am also surprised a memory limit was exceeded.

Anyway, thanks for the feedback. ~Steve