Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2013-07-24 01:18:22 +0400
committerAlessandro Ranellucci <aar@cpan.org>2013-07-24 01:18:22 +0400
commitaa2ad3bbd2f4533e869a5a756d06cd017d2b0ac7 (patch)
treefee0fcac115dbaf67f5b6f185d5f598026457882 /lib
parent9d13a90837a7b019ccda6847205a285a7cf73147 (diff)
Fix garbage collection of shared data. #1348
Diffstat (limited to 'lib')
-rw-r--r--lib/Slic3r.pm19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm
index a3761ac6b..aac355b36 100644
--- a/lib/Slic3r.pm
+++ b/lib/Slic3r.pm
@@ -86,7 +86,12 @@ sub parallelize {
my $q = Thread::Queue->new;
$q->enqueue(@items, (map undef, 1..$Config->threads));
- my $thread_cb = sub { $params{thread_cb}->($q) };
+ my $thread_cb = sub {
+ my $result = $params{thread_cb}->($q);
+ Slic3r::thread_cleanup();
+ return $result;
+ };
+
@_ = ();
foreach my $th (map threads->create($thread_cb), 1..$Config->threads) {
$params{collect_cb}->($th->join);
@@ -96,6 +101,18 @@ sub parallelize {
}
}
+# call this at the very end of each thread (except the main one)
+# so that it does not try to free existing objects.
+# at that stage, existing objects are only those that we
+# inherited at the thread creation (thus shared) and those
+# that we are returning: destruction will be handled by the
+# main thread in both cases.
+sub thread_cleanup {
+ # prevent destruction of shared objects
+ no warnings 'redefine';
+ *Slic3r::Object::XS::ZTable::DESTROY = sub {};
+}
+
sub encode_path {
my ($filename) = @_;
return encode('locale_fs', $filename);