Heroku, Oink and R14 errors. Can one line of code need 70MB of memory?

85 views Asked by At

I've been somewhat concerned at the number of R14 errors I'm getting on Heroku recently.

I don't know if this has anything to do with using Unicorn. Or having recently installed New Relic or Logentries. I really can't work it out.

I have "installed" Oink and have just received the following analysis but have no read idea how to fully understand what it's trying to tell me.

---- MEMORY THRESHOLD ----
THRESHOLD: 0 MB

-- SUMMARY --
Worst Requests:
1. Nov 13 02:53:51, 70836 KB, messages#getmessagecount
2. Nov 13 02:03:04, 65836 KB, messages#getmessagecount
3. Nov 13 02:21:46, 60236 KB, messages#getmessagecount
4. Nov 13 01:32:47, 6328 KB, messages#deletemessage
5. Nov 13 01:33:43, 6328 KB, locations#sendprofiles
6. Nov 13 01:32:56, 6328 KB, messages#deletemessage
7. Nov 13 01:32:58, 6328 KB, messages#deletemessage
8. Nov 13 01:32:49, 6328 KB, messages#deletemessage
9. Nov 13 01:47:46, 5300 KB, messages#getmessagecount
10. Nov 13 03:09:56, 5300 KB, messages#getmessagecount

Worst Actions:
9, messages#deletemessage
7, messages#getmessagecount
1, locations#sendprofiles
1, photos#photodatarequest
1, messages#getmessages

Aggregated Totals:
Action                      Max Mean    Min Total   Number of requests
messages#getmessagecount    70836   29814   464 208700  7
messages#deletemessage      6328    3016    180 27144   9
locations#sendprofiles      6328    6328    6328    6328    1
photos#photodatarequest     460 460 460 460 1
messages#getmessages        300 300 300 300 1

I'm concerned, as a layman, that my message#getmessagecount is eating a LOT of memory. Is that what the above means?

If so ... the routine is simply:

def getmessagecount

    @messagecount = Message.where(recipient: current_user, messageSysMessCode: 0, messageAdminMessage: false).count

  end

And I have no idea how this could be "leaking" memory.

The graph of memory usage on Heroku over the last day looks like:

enter image description here

I'm using Ruby 2.1.4 and Rails 4.1.7 if that's any help. I'm using two Web dynos and one Worker.

Oh ... and my delete message routine is:

def deletemessage

@message = Message.where(recipient_id: current_user.id, id: params[:messageID]).first
if (@message)
  @message.delete
  @code = "OK"
else
  @code = "Couldn't delete message"
end

end

This is killing my performance (if that's the right thing to say) every 3 hours or so. I have no idea why this is ramping up every 10 minutes (which I hopefully infer from reading the graph). 10 minutes might be significant as I have an iPhone app which is polling the getmessagecount routine every 10 mins with a single test app. I can only wonder what will happen if 10 copies of the app (or 1,000's) start hitting the server?

Any help would be very deeply appreciated.

0

There are 0 answers