Best way to debug memory issues?

So am slowly running out of memory on one of my imps (well, if you call several hours slowly). I can’t figure it out for the life of me (I will eventually do a full code review, but until then…).

I thought maybe printing all the globals would do it, but the only globals that aren’t functions or classes (since they don’t grow over time) and I am not seeing anything surprising.
I only have one object (a blob, that grows and shrinks), but I don’t see it getting bigger over time.

The one thing I do, do, is I send this blob up to the agent frequently. Anyone notice similar memory growth with sending data back and forth with the agent?

Well, it takes me posting to think of some answers. As far as the agent is concerned, I could always just comment out that code and see if the memory stills grows…

So not related to agent calls…Going to create a new thread in a public area.

Moved to General Discussion.

My thought is you could probably walk all the globals and calculate a rough size value. Then maybe print these out over time (in tree form).

Don’t know if you can get the instance variables of a Class instance (iterate them) without having knowledge about the class, though…

Anyone else do any special debugging and have hints?

Also, I think my problem was I was resizing a blob:

b.seek(0);
b.resize(0);

When I replaced that with:

b = blob(0);

It has gone away.

This is a blob that reads in packets (between 8 and 20 bytes in length), then is reused.

Hmm. That shouldn’t have caused a leak. Can’t replicate it on an imp here, but if you have code that can we’d love to see it…

Just checking that you’ve found imp.getmemoryfree() for keeping an eye on memory problems…

Peter

A couple of things.

  1. I am using imp.getmemoryfree(), which has been VERY helpful! I can watch the growth over time, but it seems to go up, then down, then back up again, but over the long haul, something is leaking

  2. Looks like the seek/resize verses new blob was not real. I put that workaround in and eventually it ran of memory. So, either I have multiple leaks, or there is just specific situations that cause this to happen

Most of my complex logic is in the agent, so the device code is pretty basic…