garbage-collector | Garbage collector implementation in Rust for Rust | Wrapper library
kandi X-RAY | garbage-collector Summary
kandi X-RAY | garbage-collector Summary
Garbage collector implementation in Rust for Rust
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of garbage-collector
garbage-collector Key Features
garbage-collector Examples and Code Snippets
Community Discussions
Trending Discussions on garbage-collector
QUESTION
In AOT compiling Dart for iOS Android (Dart Developer Summit 2016):
iOS restriction: Can't JIT
And also, from reading an article from the dart team: Flutter: Don’t Fear the Garbage Collector, I read:
QuestionIn debug mode, most of Dart’s plumbing is shipped to the device: the Dart runtime, the just-in-time compiler/interpreter (JIT for Android and interpreter for iOS), debugging and profiling services.
I wonder what the differences are between these 2 concepts, for dart specifically. Why can't iOS support JIT compilation but it can support a Dart interpreter?
Non-questionThis is not about AOT vs JIT compilation, which is the more common question. You can find out about that here.
I also already know the difference between an Interpreter and a Compiler: Interpreter executes the code step by step in a higher level form, instead of compiling it to machine code, like JIT and AOT execution.
...ANSWER
Answered 2021-Oct-01 at 14:11There aren't any technical reasons for iOS not to support the Dart JIT compiler, it's due to a security policy by Apple. Also this limitation is not Dart specific, it affects every JIT compiler out there.
A JIT compiler needs to create new machine code on the fly and write it to executable pages, but on iOS that can only be done by apps with the "dynamic-codesigning" entitlement. This entitlement is granted for example to 1st party apps using JavaScriptCore, but not 3rd party apps.
This means App Store apps cannot write to executable memory, and so a JIT cannot be embedded in them. You can run JIT accelerated JavaScript using a WKWebView
(which runs in a separate process with 1st party entitlements) but you cannot run your own JIT compiler on iOS.
An interpreter w/o a JIT on the other hand never generates new machine code so it can run without problems on iOS (though the App Store review process still imposes restrictions on what scripts it is allowed to run.)
Over the years there have been several exploits to get a JIT working, allowing for example to switch pages from +w to +x and back, but never both at the same time, but it seems currently none of those work and using a JIT in a 3rd party app is simply not possible. Even if exploits are still available, the Dart team wouldn't rely on iOS vulnerabilities that could be fixed at any time, or worse, cause apps to be flagged as malicious.
Note you'll find articles online talking about how iOS 14 allows 3rd-party apps to use a JIT compiler, but that seems to be limited to apps sideloaded via developer tools so it's not relevant for Dart / Flutter, which target devs who want to distribute their apps via the App Store.
QUESTION
Oracle documentation https://docs.oracle.com/javase/9/gctuning/garbage-first-garbage-collector.htm#JSGCT-GUID-98E80C82-24D8-41D4-BC39-B2583F04F1FF says that XX:G1HeapRegionSize must be power of 2 but there is no restriction in setting any value between 1m to 32m.
Question :
1.Can anyone explain why XX:G1HeapRegionSize must be power of 2 ?
2.For applications that deals with lots humongous objects, after extensive testing and analysing GC causes, GC throughput , GC pause time etc.,the setting XX:G1HeapRegionSize=10m seems to be appropriate. Is there any problem in setting 10m heap region for -Xmx12g ?
...ANSWER
Answered 2021-Aug-17 at 04:22Can anyone explain why XX:G1HeapRegionSize must be power of 2 ?
Simply because that is how Oracle has implemented the G1 collector.
When implementing something like a garbage collector, you need to make design choices in order for it to work. There are probably a number of detailed reasons why the G1 designers made these particular choices. The general themes will be to optimize performance in critical G1 code paths (e.g. the write barriers) and/or to avoid unnecessary complexity in the G1 code base as a whole.
(For example, if the size of a region is a power of two, and if each one starts on an address that is divisible by the region size, then you can use masking to efficiently compute which region an address belongs in. If you can save some instructions in the write barrier code, that could mean a couple of percentage points of performance for the entire JVM. I won't go into more detail ... but you can look up the literature.)
But the reasons are moot. You either live with the G1 restriction, or you select a different garbage collector that is better for your use-case.
Is there any problem in setting 10m heap region for -Xmx12g ?
Well ... it won't work ... because of the restriction that you have already found.
QUESTION
When is deinit
exactly called?
Is it like C++
guaranteed to be called when last reference gets out of scope (by return, throw or exit)?
Or is Swift
using Garbage-Collector?
ANSWER
Answered 2021-Aug-14 at 09:51The deinit
is intended to release resources (such as freeing memory that is not under ARC).
(Thanks to Martin and Rob's input, we can conclude below)
When isdeinit
called?
Usually, when last strong-reference gets out of scope,
deinit
is called instantly (then deallocation happens).
- But if affected by
autorelease
feature,deinit
is called significantly later, long after last reference gets out of scope (whenautorelease
pool is drained). - And when App is terminating,
deinit
is guaranteed to never get called!? (ifdeinit
was not already called). - Also in extremely common cases,
deinit
is called before strong-ref-variable's scope ends:In Swift unlike other languages, when we set a weak-reference equal to a strong-reference, it could result to
nil
(which is absolutely allowed by Swift).This happens if compiler detects that the remaining lines of scope, have NOT any strong-reference.
Possible workaround is using
withExtendedLifetime(_:_:)
global-method, like:
QUESTION
For an amateur developer, the mountain of advice and discussions on Stackoverflow about how to make sure COM objects are cleaned up properly after running an Office VSTO add-in are confusing to put it mildly. The advice is all over the place, from "don't do anything" this will be done for you, to explicitly starting garbage collection (once, or no that is not foolproof, needs to be done twice), to using Marshal.ReleaseComObject to clean up all the COM objects yourself (which requires you to keep track of all COM objects you use).
Some experts with many years of experience developing Office add-ins are adamant that cleaning up COM objects yourself is the way to go for stable, predictable code behavior: https://www.add-in-express.com/creating-addins-blog/2020/07/20/releasing-com-objects-garbage-collector-marshal-relseasecomobject/
So I decided to go the safe route and clean up COM objects as soon as I'm done using them myself, have to make a decision to go forward.
My question for Visio is though, to speed up the code Visio has several functions that allow us to read data from many Visio shapes at once, for instance Page.GetFormulas. Reading data from hundreds of Visio shapes at once like this performs significantly better than reading data from shapes one at a time. Going across the interop once rather than several hundred times is a boon for performance.
I wonder though if this works if I need to clean up all COM objects afterwards, as I know reading data from a shape involves the Visio Cell object which is now used/referenced implicitly.
What is happening 'under the hood' when I call bulk functions like Page.GetResults and Page.DropMany and is this going to lead to instability if I am unable to clean up all the resulting COM objects myself.
Thank you for sharing your insights this is a VERY confusing topic for an amateur developer like myself.
...ANSWER
Answered 2021-Jul-30 at 17:51If you want to make sure every single Visio COM object is dead before exiting, you could try this (on unload for example, i.e. in the ThisAddIn_Shutdown, twice to make sure all generations are killed).
QUESTION
I have read that Rust's compiler "inserts" memory management code during compile time, and this sounds kind of like "compile-time garbage collection".
What is the difference between these two ideas?
I've seen What does Rust have instead of a garbage collector? but that is about runtime garbage collection, not compile-time.
...ANSWER
Answered 2021-Mar-15 at 17:40Compile-time garbage collection is commonly defined as follows:
A complementary form of automatic memory management is compile-time memory management (CTGC), where the decisions for memory management are taken at compile-time instead of at run-time. The compiler determines the life-time of the variables that are created during the execution of the program, and thus also the memory that will be associated with these variables. Whenever the compiler can guarantee that a variable, or more precisely, parts of the memory resources that this variable points to at run-time, will never ever be accessed beyond a certain program instruction, then the compiler can add instructions to deallocate these resources at that particular instruction without compromising the correctness of the resulting code.
(From Compile-Time Garbage Collection for the Declarative Language Mercury by Nancy Mazur)
Rust handles memory by using a concept of ownership and borrow checking. Ownership and move semantics describe which variable owns a value. Borrowing describes which references are allowed to access a value. These two concepts allow the compiler to "drop" the value when it is no longer accessible, causing the program to call the dtop
method from the Drop
trait).
However, the compiler itself doesn't handle dynamically allocated memory at all. It only handles drop checking (figuring out when to call drop
) and inserting the .drop()
calls. The drop
implementation is responsible for determining what happens at this point, whether that is deallocating some dynamic memory (which is what Box
's drop
does, for example), or doing anything else. The compiler therefore never really enforces garbage collection, and it doesn't enforce deallocating unused memory. So we can't claim that Rust implements compile-time garbage collection, even if what Rust has is very reminiscent of it.
QUESTION
I am running my code on AWS Lambda and I have some performance issues depending on the memory I allocate to the Lambda.
For the same call:
...ANSWER
Answered 2021-Mar-03 at 22:05I guess one way would be via shell substitution. Then you can put whatever calculation you want in there. For example, on my machine, something like this computes half the available memory:
QUESTION
ANSWER
Answered 2021-Jan-28 at 09:14The problem with increasing memory consumption in your code is that you have to delete the handle returned by GetHbitmap
by calling DeleteObject
, e.g. as explained here: https://stackoverflow.com/a/5827468/1136211
Besides that, in a WPF application you would implement the whole logic in a completely different way.
You would not use bitmap resources in Properties/Resources.resx
but instead just add the image files to your Visual Studio project, e.g. in a project folder named "Images". Then set the Build Action of those files Resource
as e.g. shown here: https://stackoverflow.com/a/12693661/1136211
On startup, load all those image resources into a list. Then start a DispatcherTimer that cyclically assigns them to the Source property of an Image element.
QUESTION
I want to install the Boehm garbage collector garbage collector on MacOS. I looked at this guide but it did not help; invoking brew install libgc
did nothing. Here is my example code that I am trying to run:
ANSWER
Answered 2020-Nov-24 at 21:13When I installed libgc on mac, as you did, the files were installed to /usr/local/Cellar/bdw-gc/
. Then, when it came time to compile my code I had to run:
QUESTION
I've configured access to my K8s cluster, set up all needed pods &services, created secrets with YAML files, but this simple command:
...ANSWER
Answered 2020-Nov-17 at 18:22I found the solution: I had to set the role kms.keys.encrypterDecrypter
to the service account which is used to control Kubernetes cluster in the settings of Yandex.Cloud project catalog.
QUESTION
I've been trying to switch from CPython to PyPy recently, and while trying to solve a bug, more precisely an error 139 with SIGSEGV signal (so a Segmentation Fault), I tried to investigate the garbage collection through the GC module by looking at the gc.garbage
attribute list.
In CPython, I could for example run the following piece of code (taken from there with modifications) to check lingering objects in the GC garbage list:
...ANSWER
Answered 2020-Nov-17 at 14:14It's not possible to do what you're trying to do. Even on CPython, the list gc.garbage
will by far not contain all objects that are reclaimed, even if you enable debug mode, but only the ones that have been found to be in cycles. That's unlikely to be relevant to anyone except the authors of the cycle-finding logic itself. And on PyPy, the notion of "being in a cycle" is even less relevant; as you have probably understood already from the various links you point to, PyPy's GC is quite different.
No, there is no way to inspect all objects that are dying. In fact PyPy's GC is optimized for objects that die young, and for all of these (which are typically 80%-90% of all objects in a program) then the structure of the GC is such that there is no way to even know what the dying objects are. These 80%-90% of objects occupy space that is reclaimed in bulk, not one by one.
In all likelihood, you're looking at your problem from the wrong end. If you can describe a bit more what your problem is, we can try to come up with better solutions. In the meantime, note that you can run pypy -X faulthandler
to get at least some kind of traceback when you get a segfault.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install garbage-collector
Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page