On Wed, Jan 19, 2000 at 11:21:31AM +0100, [EMAIL PROTECTED] wrote:
> I'm still working on a distributed client/server system on the base of
> Event. My test server grows and grows if stressed by a lot of client
> connections (and at a certain point this starts to cause errors). This
> growth has been significantly reduced (at least in the amount of
> RESERVED memory reported by "top") since I use Event 0.58 (which
> includes the memory leak fix of 0.57), but it still occurs. Well, I'm
> not sure where the error is - may be in my code, may be in a module, may
> be in Event. I want to find it out. My question: is there a tool or
> module which could help me to check which data consume which amount of
> memory?
I put in some code for precisely that purpose. Event.xs has these
macros:
#define MAX_MEMORYCOUNT 20
static int MemoryCount[MAX_MEMORYCOUNT];
static void dbg_count_memory(int id, int cnt) {
assert(id >= 0 && id < MAX_MEMORYCOUNT);
MemoryCount[id] += cnt;
}
#if DEBUGGING
# define EvNew(id, ptr, size, type) dbg_count_memory(id,1); New(0,ptr,size,type)
#else
# define EvNew(x, ptr, size, type) New(0,ptr,size,type)
#endif
And then you can read the counters back into Perl with
my @counters = Event::_memory_counters();
As you can see, this is very simplistic since it doesn't keep track of
free'd memory. This was good enough for me because (IIRC) Event doesn't
free memory unless you destroy watchers. If this isn't sufficient, then
I guess I can track frees too. Let me know.
> I checked out all Devel:: modules which sound helpful to me but
> none of them seems to provide this functionality.
Does Devel::Leak work? I've used it before with some success.
--
"Never ascribe to malice that which can be explained by stupidity."
via, but not speaking for Deutsche Bank