Skip to content

Memory Leak #24

@cesaric

Description

@cesaric

Memory leak in Doctrine (http://www.doctrine-project.org/jira/browse/DC-310). Did some image resizing (images were saved as BLOBS in the DB table) and noticed it immediately with the createThumbnailImages() function below. Uncommenting "Doctrine_Manager::connection()->clear();" fixes it.

public function createThumbnailImages($params)
{
$width = $params["columns"];
$height = $params["rows"];

$q = Doctrine_Query::create()->select('pi.id')->from('ProductImage pi');
$results = $q->execute();
$image = new Gmagick();

$prodImageTable = Doctrine_Core::getTable('ProductImage');

foreach ($results as $result)
{
    $imageResult = $prodImageTable->find($result->id);
    $image->readimageblob($imageResult->image);
    $image->scaleimage($width, $height, true); // 3rd parameter, bestFit
    $imageResult->thumb = $image;
    $imageResult->save();
    $image->clear();
    unset($imageResult);
    //Doctrine_Manager::connection()->clear();
}

$image->destroy();

}

Maybe we need to implement some memory checking as Doctrine/Hydrator/Graph.php can also exceed memory limits assembling the data graph and throw an error. Maybe we create an auto paging mechanism for these cases?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions