in reply to Where are those memory leaks?

You have the prepare inside the loop, it should be outside the loop. Prepare once before the loop, then execute many times inside the loop. Don't undef the $sth. If the id is a unique id, i.e. there is only one row to fetch, don't use finish at all (unless your DBD docs tell you to) - it is usually only required when there are more rows to fetch.

Also, you didn't mention which DBD and RDBMS you are using or what platform you are on. It's unlikely that DBI itself is leaking to the extent you indicate but there may be issues with the DBD or the RDBMS or the platform.

Replies are listed 'Best First'.
Re: Re: Where are those memory leaks?
by ezekiel (Friar) on Mar 24, 2004 at 04:11 UTC

    Thanks for your response.

    I tried with the prepare outside the loop and got an "Invalid cursor state" error, so put it back inside the loop. The id is unique. The finish and undef are only there in a desperate attempt to undef everything in trying to solve the memory leak :-)

    I am using DB2 (version 7.2) on IBM/AIX hardware/operating system with the DBD:DB2 driver

      I am using DB2 (version 7.2) on IBM/AIX hardware/operating system with the DBD:DB2 driver

      You use operating system very loosly there... =)


      -Waswas