Comment 1 for bug 143917

Revision history for this message
Tres Seaver (tseaver) wrote :

I can confirm that this leak is there, and has in fact caused
me to stop using the ZRDB.Results class altogether. Here is
where the problem arises:

  - For each result set (i.e., each invocation of a SQL method),
    the Results class creates a new class on-the-fly, named 'r'.
    It creates an uppercase and lowercase alias for each column
    in the result set's schema, and sets those aliases as
    attributes of the 'r' class, in order to get their '__of__'
    methods called when the alias is requested as an attribute
    of an instance of 'r'.

  - The cycle is thus betweeen the on-the-fly class, which
    is stashed as the '_class' attribute of the Results instance,
    and the alias(es). I don't know why that 'r' class is
    unreachable for GC, but it seems to be so. I also don't
    know how to write a test for the (non)existence of the
    cycle.

My workaround was to move to using a results class which did
not attempt to DWIM the uppercase and lowercase aliases at
all: the columns can only be accessed using the same spelling
that was used in the original SQL. BBB will make this harder
to do in the ZRDB.Results module.