1
0
mirror of https://github.com/ToxicCrack/PrintABrick.git synced 2025-05-28 01:30:11 -07:00

Fix loader memory leaks

This commit is contained in:
Unknown 2017-06-08 18:00:36 +02:00
parent 80bea7f0c9
commit 11f1d9eec1
3 changed files with 16 additions and 3 deletions

View File

@ -12,6 +12,9 @@ class BricksetManager
*/
private $bricksetClient;
/**
* @var CacheProvider
*/
private $cache;
const CACHE_LIFETIME = 86400;

View File

@ -162,25 +162,33 @@ class ModelLoader extends BaseLoader
$files = $this->ldrawLibraryContext->listContents('parts', false);
$this->initProgressBar(count($files));
$index = 0;
$connection = $this->em->getConnection();
$connection->getConfiguration()->setSQLLogger(null);
foreach ($files as $file) {
$this->progressBar->setMessage($file['basename']);
if ($file['type'] == 'file' && $file['extension'] == 'dat') {
$connection = $this->em->getConnection();
$connection->beginTransaction();
try {
$this->loadModel($this->ldrawLibraryContext->getAdapter()->getPathPrefix().$file['path']);
// clear managed objects to avoid memory issues
if($index++ % 50 == 0) {
$this->em->clear();
}
$connection->commit();
} catch (\Exception $exception) {
$connection->rollBack();
$this->logger->error($exception->getMessage());
}
$connection->close();
}
$this->progressBar->advance();
}
$connection->close();
$this->progressBar->finish();
}

View File

@ -152,6 +152,8 @@ class StlRendererService
throw new ConvertingFailedException($file, 'POV');
}
unset($incFile);
return $outputFile;
}