The tag has no wiki summary.

learn more… | top users | synonyms

3
votes
2answers
83 views

COM - with great power comes great responsibility, but at what cost? (looking for advice on coding practices when working with COM)

What is best (or commonly accepted) practice for where to declare COM object variables (scope) and how to handle cleaning them up when using structured error handling? I just spend a whole load of ...
24
votes
8answers
3k views

Is overriding Object.finalize() really bad?

The main two arguments against overriding Object.finalize() is that: You don't get to decide when it's called. It may not get called at all. If I understand this correctly, I don't think those are ...
1
vote
3answers
495 views

How does garbage collection compare to reference counting? [duplicate]

I starting working through an online course on iOS development in the new language from Apple, Swift. The instructor made a point that raised this question in my mind. He said something to the ...
0
votes
1answer
72 views

Why is it faster to compact a portion of the managed heap than the entire heap?

I was reading this article on MSDN. In the first paragraph under the "Generations and Performance" subheading is written: First, it is faster to compact the memory for a portion of the managed ...
0
votes
1answer
130 views

Changing the Garbage Collector on your JVM [closed]

My understanding is that the JVM specification only defines the behavior of a garbage collector, but does not provide implementation details. This means it is up to the JVM implementation to build the ...
-3
votes
1answer
131 views

What should be kept in mind when writing a garbage collector? [closed]

I would like to learn the important concepts behind garbage collector design. My priority is conceptual clarity, not runtime efficiency. In particular, I would like to know: What data structures are ...
3
votes
3answers
233 views

How do you find out what resources are unmanaged?

Looking through the .NET documentation, specifically the WebRequest class, I don't see any information indicating that I should wrap an instantiation of it in a using statement. Even the provided ...
0
votes
2answers
119 views

Objects or primitives as arguments

I have come across the term "garbage disposal" and now I'm worried about using up too much memory. Apparently (correct me if I'm wrong) every time an object is created, memory is reserved for it, and ...
109
votes
9answers
9k views

When is it a good idea to force garbage collection?

So I was reading a question about forcing the C# garbage collector to run where almost every single answer is the same: you can do it, but you shouldn't - except for some very rare cases. Sadly, ...
3
votes
1answer
249 views

Does the JVM's Garbage Collector clean the entire JVM HotSpot memory (C-Heap, Java Heap and Permanent Generation space) or just Java Heap?

I know that the JVM has some JVM HotSpot memory which is further divided into three areas: Java Heap Permanent Generation Space Native Heap (C-Heap) I know that Java has automatic garbage ...
1
vote
1answer
116 views

Garbage collection & memory leaks on hash tables

I was reading R. Read's How to be a programmer, and I came accross something I didn't understand: ...even with garbage collection, you can fill up all memory with garbage. A classic mistake is ...
1
vote
0answers
450 views

How does AngularJS manage scope in ng-repeats?

I have a table that has around 60 rows and 20 columns. Each cell has a directive with an isolated scope. I use 2 nested ng-repeats to generate the table (one for rows and one for columns), but I'm ...
1
vote
2answers
220 views

When should we work on GC optimization?

So, I've learnt about how GC works and how can I monitor it via VisualVM, but my question is about why we should ever perform GC optimization? In our web project (JSF/Spring/Hibernate) we haven't ...
3
votes
2answers
184 views

Do compilers attach the Garbage Collector to the final executable?

Since the Garbage Collector is part of the language implementation (not OS, etc.), does the compiler has to attach the GC to the final executable? Or is it like a dependency that has to be already ...
0
votes
2answers
379 views

Advantages of unmanaged code [closed]

tl;dr: Why would I ever choose to write/compile unmanaged1 code? Lets assume that I am starting a new project. I have decided to write in a C-like language - probably one of C, C++, C# or Java. C# ...
6
votes
1answer
229 views

Does assigning NULL in a GC'ed Environment have similar effects to using free()?

I was just writing a function (in C# in this case) that stored huge amounts of data in a local variable early on in the code, let's say at 5% of the functions code. After that point, the data in this ...
1
vote
2answers
309 views

Do GC generations have any purpose (for an application programmer) other than answer to “tricky” HRs' questions?

I'm using C# for a several years, never actually willing (until I really need to) to dig into its "deep" mechanics and to intervene in GC work, IL-compiled code and so on. My point is if you ever ...
3
votes
7answers
212 views

What if any languages treat undisposed resources as an error?

I've seen lots of code like the following example. It's in Python, but the same mistake is made in all languages with managed resources: f = open('foo.txt', 'rb') for line in f: print line That's ...
8
votes
3answers
1k views

What optimizations can be done for soft real-time code in C#?

I'm writing a soft real-time application in C#. Certain tasks, like responding to hardware requests coming in from a network, needs to be finished within a certain amount of milliseconds; however it ...
2
votes
3answers
302 views

Uses for System.gc() in Java [closed]

In Java, there is a method called System.gc(), which calls the garbage collector (or rather, "suggests" to the JVM to run the GC). Are there valid reasons to call this method? I'm thinking that it ...
2
votes
1answer
149 views

will having an event with subscribers prevent an object from being GC'ed?

I have an object, which has an event which in turn has subscribers. I know that the subscribing objects won't get GC'ed since the delegate they stored for the event is connected to them, thus keeping ...
1
vote
2answers
360 views

Do immutable objects that constantly change impact memory/performance?

I'm writing a program that goes into a loop and keeps changing the state of some models (similar to a game). Naturally, many things are mutable. However, I'm also writing some classes that are ...
42
votes
7answers
4k views

Why is the finalize method included in Java?

According to this post, we should never rely on the finalize method to be called. So why did Java include it in the programming language at all? It seems like a terrible decision to include in any ...
3
votes
1answer
439 views

C# server side application 100 GB dataset + Garbage Collection

If I have server with 256 Gb of ram. I was wondering can I create a C# application which has a 100 GB of memory footprint? I want to create a dictionary like ...
2
votes
0answers
67 views

How can I find the start of a native method?

For a hobby project, I'm writing an x86 GC and JIT. For the GC, I need to maintain information about the stack layout (it's a precise GC), for which I need to be able to find out which method the IP ...
0
votes
1answer
169 views

Why/how does Java use a controlled mechanism to pause threads for GC?

I know that Java uses a controlled mechanism to allow threads to be paused. If I understood correctly, they put a read from a protected page at the end of e.g. loops, and change the protection of that ...
4
votes
5answers
1k views

Why is there no deterministic object destruction in Java? [duplicate]

I understand and enjoy the benefits of the Garbage Collection in Java. However I don't understand why there is no way in Java to explicitly (and quickly) destroy an object. Surely this could be useful ...
2
votes
2answers
205 views

Does a vm implemented in garbage collected language need a garbage collector?

This is more of a theoretical question. If jvm is implemented in go which itself is a garbage collected language, then does that jvm need a separate garbage collector to be implemented for its own ...
-1
votes
2answers
222 views

Is it possible to implement a native compiler for a 'managed language' such as Java?

In most cases, it is possible to create both a native compiler and an interpreter for a programming language. The compiler would simply convert the source code to machine code, and the interpreter ...
13
votes
3answers
1k views

Would using a hash table in garbage collection solve the stop the world problem of mark and sweep?

In mark-sweep-compact garbage collection algorithm you have to stop-the-world when relocating objects because reference graph becomes inconsistent and you have to replace values of all references ...
0
votes
4answers
733 views

How to design an IDisposable that unconditionally needs to be disposed?

Consider a class that implements IDisposable, and that has members in such a way that it will never become eligible for garbage collection when it is not disposed. And as it will not be garbage ...
31
votes
8answers
3k views

Disadvantages of scoped-based memory management

I really like scope-based memory management (SBMM), or RAII, as it is more commonly (confusingly?) referred to by the C++ community. As far as I know, except for C++ (and C), there's no other ...
3
votes
5answers
715 views

What exactly is the Garbage Collector in Java?

I think I generally know what the Garbage Collector in Java does, but It's praised a lot, so I thought maybe I'm missing something about it's functionality. What I know is, that the GC takes care of ...
3
votes
2answers
314 views

What use is a non-zeroing weak reference?

When reading about the various options for working with things like ARC / GC, I often come across explicit wording about which weak references are zeroing (ie, your reference becomes nil/null/0 when ...
11
votes
5answers
2k views

Why did the team at LMAX use Java and design the architecture to avoid GC at all cost?

Why did the team at LMAX design the LMAX Disruptor in Java but all their design points to minimizing GC use? If one does not want to have GC run then why use a garbage collected language? Their ...
7
votes
4answers
750 views

Why not free memory as soon as its reference counter hits zero [duplicate]

A lot of languages like Java and C# have garbage collectors that free memory when that memory no longer has any reference. Yet they don't immediately free it after the reference counter hits zero but ...
2
votes
1answer
325 views

Python garbage collection giving me a hard time

Context: I am developing a web application using webapp2 web-framework with python to be hosted on GAE. The web application (web-app from now on), is a chess variant. Being a first timer, I have ...
0
votes
1answer
123 views

Multiple Instantiate of 1 class affects memory?

I am currently struggling with memory handling. I have an if statement and each case instantiate a new object from a class. Does this affect the memory allocation in java? switch() { case 1: test t1 ...
12
votes
2answers
1k views

Since Garbage Collection is non-deterministic, why isn't it used for secure random number generation?

I get that /dev/random is a good source of entropy, and is what is usually used-- It's just as I'm reading up on GC, at least in Java, it seems accepted that the garbage collection daemon executes ...
33
votes
2answers
6k views

Why are reference-counting smart pointers so popular?

As I can see, smart pointers are used extensively in many real-world C++ projects. Though some kind of smart pointers are obviously beneficial to support RAII and ownership transfers, there is also a ...
1
vote
3answers
282 views

Garbage collectors and pointers/ reference

I am a little confused on both pointers and reference. From my understanding pointers are addresses in memory. If I pass a variable using pointers and reference to a function, any manipulations of ...
7
votes
6answers
1k views

Demonstration of garbage collection being faster than manual memory management

I've read in many places (heck, I've even written so myself) that garbage collection could (theoretically) be faster than manual memory management. However, showing is a lot harder to come by than ...
3
votes
1answer
396 views

Are C or C++ The Only Viable Languages for a GC

Background I have just finished writing a compiler for a functional language compiling to the JVM as a learning project. However, since I'm just doing this to learn, I thought it might be interesting ...
26
votes
3answers
2k views

Except garbage collector, what else makes Java a non real time programming language

Except the garbage collector, what are some other features in Java that make it unsuitable for real time programming? On the net, whenever Java vs C++ is discussed with regards to real time ...
9
votes
4answers
506 views

Is Non-Deterministic Resource-Management a Leaky Abstraction?

From what I can see, there are two pervasive forms of resource-management: deterministic destruction and explicit. Examples of the former would be C++ destructors and smart pointers or Perl's DESTROY ...
15
votes
1answer
378 views

When a garbage collector compacts objects in the heap, does it change the references on the stack?

This seems like a simple question, but after a lot of reading on the subject, I still haven't found a definitive answer (perhaps because it is so simple). My question is this: when a garbage ...
8
votes
2answers
283 views

How does a concurrent garbage collector deal with variables?

Let's say it is a concurrent mark-and-sweep garbage collector. When such GC handles constant pointers it just walks through them (starting from roots), and marks every encountered data block. Then ...
24
votes
4answers
12k views

When to use weak references in .Net?

I have not personally come across a situation where I've needed to use WeakReference type in .Net, but the popular belief seems to be that it should be used in caches. Dr Jon Harrop gave a very good ...
3
votes
2answers
995 views

Memory management for fast message passing between threads in C++

Suppose there are two threads, which communicate by asynchronously sending data messages to each other. Each thread has some kind of message queue. My question is very low level: What can be expected ...
2
votes
1answer
172 views

Is it appropriate to try to control the order of finalization?

I'm writing a class which is roughly analogous to a CancellationToken, except it has a third state for "never going to be cancelled". At the moment I'm trying to decide what to do if the 'source' of ...