mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-29 10:10:25 -07:00
Fix loader memory leaks
This commit is contained in:
parent
80bea7f0c9
commit
11f1d9eec1
@ -12,6 +12,9 @@ class BricksetManager
|
||||
*/
|
||||
private $bricksetClient;
|
||||
|
||||
/**
|
||||
* @var CacheProvider
|
||||
*/
|
||||
private $cache;
|
||||
|
||||
const CACHE_LIFETIME = 86400;
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -152,6 +152,8 @@ class StlRendererService
|
||||
throw new ConvertingFailedException($file, 'POV');
|
||||
}
|
||||
|
||||
unset($incFile);
|
||||
|
||||
return $outputFile;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user