Re: More object index weirdness

[prev] [thread] [next] [Date index for 2004/09/16]

From: Perrin Harkins
Subject: Re: More object index weirdness
Date: 15:30 on 16 Sep 2004
On Thu, 2004-09-16 at 11:16, William McKee wrote:
> At any rate, I know the object is still in the index because I can dump
> the contents of the Live_Objects hash using the hack I mentioned
> yesterday. Also, if I add remove_from_object_index, the code works
> successfully.

Okay.  What does the code where you delete it look like?  I'm not sure
if your idea of deleting the object is the same as mine, because in mine
there is no way you could reload it after deleting it.

> > The old record is only kept around if you have a copy of it in memory
> > somewhere.
> 
> But why wouldn't it be updated/removed if it's no longer in the
> database?

You have a copy of the object sitting in a variable somewhere in your
code.

> Does the index not get refreshed when a record is reloaded?

The index never gets refreshed in any situation.  An object is either in
memory or not, and if it is in memory, the index has a reference to it.

> If not, then it would seem to me that the index is acting more like a
> cache.

No, your code is acting like a cache and the index is making that
visible to you.

> I suppose it could be the case that existing objects take
> precedence over incoming objects when an object is already in the index.

That's essentially the whole point of the index: if you have an existing
object, it will not make another one for the same key.  It will give you
back the existing one.

> I'm beginning to understand that my mystery objects are due to
> references being kept in memory; I'm just having trouble tracking down
> where they are being stored. I'm using strict and try to stay away from
> globals. Looking through /perl-status on my webserver, I don't see any
> scalars or hashes sticking around in my modules (/perl-status?sybdump).

Could be an accidental closure created by defining a lexical outside of
a sub where you use that lexical.

> Ahha! It could be that I have multiple instances of Apache running, each
> with it's own object index. I remove the object in process A but it's
> still hanging around in process B.

That could be, but you need to be more precise with your terms if you
can't show code.  Does "remove the object" mean you clear a variable
that held it, or remove it from the index, or call $obj->delete(), or
something else?

> But that would still mean I'm keeping
> objects around in memory and simply doing a remove_object_from_index in
> process A wouldn't affect process B (would it?).

In-memory changes in one process will never affect the memory of another
process.  Deleting something in the database deletes it for everyone of
course (although people sometimes get confused by isolation levels,
especially with InnoDB tables).

> I really need to find
> why that object is being maintained in memory. Any pointers?

I'm still not sure what you're doing, so it's hard to offer good
advice.  Standard debugging techniques apply, so I would start by
working backwards from the problem, dumping out all the variables that
might contain that object which should be gone.

- Perrin

(message missing)

More object index weirdness
William McKee 13:46 on 16 Sep 2004

Re: More object index weirdness
Perrin Harkins 14:09 on 16 Sep 2004

Re: More object index weirdness
William McKee 15:16 on 16 Sep 2004

Re: More object index weirdness
Perrin Harkins 15:30 on 16 Sep 2004

Re: More object index weirdness
William McKee 16:19 on 16 Sep 2004

Re: More object index weirdness
Perrin Harkins 16:40 on 16 Sep 2004

Re: More object index weirdness
William McKee 17:02 on 16 Sep 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52