The tag has no usage guidance, but it has a tag wiki.

learn more… | top users | synonyms

1
vote
1answer
136 views

What are the significant memory management models aside from Java (GC) and C++ (manual approach)? [closed]

There are at least two distinct memory management models: Java (we do it for you) C++ (it is your responsibility) I have two questions: (1) Is GC language specific or compiler specific? (2) Do ...
4
votes
7answers
648 views

C++ delete vs Java GC

Java garbage collection takes care of dead objects on the heap, but freezes the world sometimes. In C++ I have to call delete to dispose a created object at the end of it's life cycle. This delete ...
48
votes
8answers
14k views

What happens to garbage in C++?

Java has an automatic GC that once in a while Stops The World, but takes care of garbage on a heap. Now C/C++ applications don't have these STW freezes, their memory usage doesn't grow infinitely ...
1
vote
4answers
218 views

Readability & Performance: Is it better to allow the Java garbage collector to clear a datastructure?

I work with large HashMap's and ArrayLists. When not needing them to be in memory any longer, I use myArray.clear(); to free up the memory. When my colleague saw that line, he changed it to myArray ...
2
votes
1answer
99 views

When should I worry about freeing objects from memory in Python?

I've been reading a few different guides and tutorials, as I am interested in learning some best practices of programming. I was reading the How to be a Programmer guide, and there is a section about ...
1
vote
1answer
150 views

Make PHP sessions truly last until the browser closes, and regenerating session on page requests

We have an issue where sessions are ending after a short time, 1440 seconds according to gc_maxlifetime settings which seems consistent with the issue. The PHPSESSID says it will expire when the ...
4
votes
1answer
90 views

In SPA what happens in terms of memory and performance when user hops across all the pages?

Imagine a humongous web aplication built using Single Page Application framework such as AngularJS. With its each route it downloads a couple of HTML template files. Each of these template files ...
7
votes
6answers
1k views

Does it make sense to use the term “Space Leak” with regard to Java?

EDIT: To clarify, I am not suggesting that leaks don't happen in a managed application. I'm simply pondering about how we talk about them. There are some highly upvoted discussions about memory ...
2
votes
1answer
205 views

Why is checking weird bit errors important in garbage collectors?

Here's a rough translation of a tweet by @xharaken. "Space rays hit computers and mess up the bits in the memory" "hardware bugs mess up the bits in the memory" such things almost never happen, ...
2
votes
1answer
171 views

In garbage collecting languages (JavaScript), can I securely overwrite data?

Realizing that garbage collection and memory management is implemented differently in different environments for sake of simplicity this question will focus on JavaScript (either V8 or Seamonkey). I ...
19
votes
2answers
461 views

How different is garbage collection in pure languages?

In a pure language like Haskell, all data is immutable and no existing data structures can be changed in any way. Additionally, many algorithms on immutable data and functional programming patterns ...
3
votes
2answers
98 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 ...
29
votes
8answers
7k 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 ...
11
votes
3answers
9k 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
76 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
292 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
418 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 ...
4
votes
3answers
414 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
183 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 ...
118
votes
9answers
16k 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
447 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
294 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 ...
2
votes
0answers
743 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
248 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
212 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
537 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
245 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
319 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
226 views

What if any languages treat undisposed resources as an error? [closed]

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
2k 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
367 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
264 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
568 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
616 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 Dictionary<DateTime,Dictionary<...
2
votes
0answers
72 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
221 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
2k 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 ...
4
votes
2answers
280 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
vote
2answers
395 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
2k 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
1k 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 ...
35
votes
8answers
4k 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
850 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
440 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 ...
21
votes
6answers
3k 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
822 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
477 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
131 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
2k 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 non-...