From: Michael Widenius Date: June 5 2009 2:41pm Subject: Re: BLOB memory deallocation (storage engine dev) List-Archive: http://lists.mysql.com/internals/36846 Message-Id: <18985.11940.328748.872482@narttu.askmonty.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi! Just noticed that I had missed this email. Better to get an answer late than never... >>>>> "Paul" == Paul McCullagh writes: Paul> Hi Vyacheslav, Paul> The engine is responsible for deallocating the buffer. Paul> However, it is not entirely obvious (to me anyway) exactly when it is Paul> safe to do this. MySQL assumes that the buffer is not freed as long as the current row is active. The buffer used for a blob can be freed: - At next read-row with the same TABLE object. - At ha_rnd_end() or ha_index_end(). Paul> I recommend making the buffer local to the handler. As far as I know, Paul> you will need a maximum of one buffer per BLOB column per handler. MyISAM uses one buffer for all blobs in the current row. Paul> At the end of the index scan or table scan you can free the buffers Paul> for the handler. Yes. You can however realloc/free the buffer also at each read_row. Regards, Monty