garbage-collection

Does the Xamarin.iOS garbage collector use a fixed MaxGeneration?

与世无争的帅哥 提交于 2019-12-24 00:54:22
问题 In my tests, Xamarin.iOS always seems to use two generations. That is, GC.MaxGeneration always returns 1 . The Xamarin Cross-Platform Performance Documentation seems to support that by referring to the Mono SGen Documentation, which states the SGen uses two generations. On the other hand, the Xamarin API Documentation of GC.MaxGeneration suggests that MaxGeneration can increase over time. Is GC.MaxGeneration fixed in Xamarin.iOS, or can it increase given enough time? Also, just in case: Has

Are child objects still alive when Object.Finalize is called by GC?

徘徊边缘 提交于 2019-12-24 00:53:11
问题 Say, I have this class: class Test { readonly object _child = new Object(); // ... ~Test() { // access _child here // ... } } Is the _child object guaranteed to still be alive when ~Test is called by the garbage collector? Or should I first "pin" the _child with GCHandle.Alloc in the constructor? 回答1: Being a readonly field _child you can't lose its reference (unless you set it to null via reflection). Which means that till the Test is garbage collected _child will stay in memory for sure.

Memory allocation for incremental garbage collection simulation in c++

陌路散爱 提交于 2019-12-24 00:35:33
问题 I need to simulate an incremental garbage collection algorithm in C++ or Java. I had a doubt based on this. As an input ( stdin from keyboard), I will be asked to allocate some memory for this code. The syntax would be: x = alloc(128KB); My question: is it ok to use malloc for the assignment? Or is there any other way to allocate memory? I had this doubt because, the size can go up to GB for the assignment, so using malloc might not be a good idea I think. 回答1: First of all, if you want to

Pointers, am I using them correctly? Objective-c/cocoa

 ̄綄美尐妖づ 提交于 2019-12-24 00:26:53
问题 I have this in my @interface struct track currentTrack; struct track previousTrack; int anInt; Since these are not objects, I do not have to have them like int* anInt right? And if setting non-object values like ints, boolean, etc, I do not have to release the old value right (assuming non-GC environment)? The struct contains objects: typedef struct track { NSString* theId; NSString* title; } *track; Am I doing that correctly? Lastly, I access the struct like this: [currentTrack.title ...];

freeing shared resources in Android app

廉价感情. 提交于 2019-12-23 20:20:03
问题 I'm writing an Android app that has both an Activity and a Service component. Furthermore, I've got a class encapsulating a resource that I am sharing in several places across both the Activity and the Service. My question is how I can figure out when to free the resource. As I understand it, Java does not have a notion of a destructor, so I can't just create a destructor in the shared object which will be called when there are no more references to the object. Android has functions such as

How to determine which GC I use?

荒凉一梦 提交于 2019-12-23 20:15:09
问题 I didn't specify any GC, and I think my JVM have not any GC be enabled by default. Of course I know that OpenJDK8 use ParallelGC by default, but I think it should can print by command line, like this: java -XX:+PrintFlagsFinal|grep Use|grep GC I expect that the output contains bool UseParallelOldGC = true {product} but it is no : bool ParGCUseLocalOverflow = false {product} bool UseAdaptiveGCBoundary = false {product} bool UseAdaptiveSizeDecayMajorGCCost = true {product} bool

Spidermonkey and Garbage Collection

爱⌒轻易说出口 提交于 2019-12-23 20:14:58
问题 I am embedding Spidermonkey in my C++ application. I need to implementing some custom Javascript functions in native C++ that pass around a jsval. I need to guard the jsval against accidental garbage collection. Is it proper for me to do this: (1) In an init routine: static jsval vp; // a STATIC variable, value unknown JSBool init((JSContext *cx, uintN argc, jsval *vp) { JS_AddValueRoot(cx, &vp); } (2) In one c++ function implementing the Javascript function setter(): JSBool setter(JSContext

How to manage lifetime of dynamically allocated QObject returned to QML?

回眸只為那壹抹淺笑 提交于 2019-12-23 19:24:56
问题 I have this code: QVariant componentFromCode(QString code) { QQmlComponent * component = new QQmlComponent(engine); engine->setObjectOwnership(component, QQmlEngine::JavaScriptOwnership); connect(component, &QQmlComponent::destroyed, this, &Factory::echo); component->setData(code.toUtf8(), QUrl()); return QVariant::fromValue(component); } But Factory::echo() is never called, which means the object gets leaked every time the function is called. This is what I have on the QML side: onClicked: {

Ninject Garbage Collection [closed]

笑着哭i 提交于 2019-12-23 18:50:27
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 8 years ago . I am using Ninject in a n-tier application consisting of services, repositories, all wired up with the UnitOfWork pattern and Ninject. Further, I have

C# GC not freeing memory [duplicate]

穿精又带淫゛_ 提交于 2019-12-23 18:46:42
问题 This question already has answers here : Understanding garbage collection in .NET (3 answers) Closed 6 years ago . I'm having an awful time with C# not freeing up memory for a large structure I'm holding in memory after I'm no longer referencing it. I've included some code below that showcases a similar problem to the one I'm having. I think I must be misunderstanding something about the GC because I'm not sure why the following code would throw an Out of Memory Exception. Does anyone know