In C# which is more memory efficient: Option #1 or Option #2?
public void TestStringBuilder()
{
//potentially a collection with several hundred items:
string[] outputStrings = new string[] { "test1", "test2", "test3" };
//Option #1
StringBuilder formattedOutput = new StringBuilder();
foreach (string outputString in ...
I was reading Java Platform Performance and section A.3.3 worried me.
I had been working on the assumption that a variable that dropped out of scope would no longer be considered a GC root, but this paper appears to contradict that.
Do recent JVMs, in particular Sun's 1.6.0_07 version, still have this limitation? If so, then I have a l...
Microsoft's new F# programming language provides the powerful combination of functional programming (first-class lexical closures and tail calls) with an efficient concurrent garbage collector that makes it easy to leverage multicores.
OCaml, Haskell, Erlang and all free Lisp and Scheme implementations that I know of do not have concurr...
Is there a way to force the flash garbage collector to clean up freed memory? I've seen that it takes a lot of time for flash to clean up not referenced memory...
...
Hi, I wonder if it is possible in a Compact Framework application to prevent the garbage collector to unconditionally stop at least one of the threads, or if it is possible to block GC collects at least in some portions of the code.
I think it has to deal with setting real time priorities, but I found a lot of advices against doing it.....
This code is causing a memory leak for me, and I'm not sure why.
[EDIT] Included code from here into question:
#include "src/base.cpp"
typedef std::map<std::string, AlObj*, std::less<std::string>,
gc_allocator<std::pair<const std::string, AlObj*> > > KWARG_TYPE;
AlInt::AlInt(int val) {
this->value = val;
this->setup();
}...
If I have the following code:
MyClass pClass = new MyClass();
pClass.MyEvent += MyFunction;
pClass = null;
Will pClass be garbage collected? Or will it hang around still firing it's events whenever they occur? Will I need to do the following in order to allow garbage collection?
MyClass pClass = new MyClass();
pClass.MyEvent += MyFun...
When working in the unmanaged world, we have to make sure that we clean up after ourselves if we have allocated memory on the heap (e.g. by using the new keyword in C++); we also have to make sure that we AddRef COM components that are created using CreateInstance and to Release it later; perhaps something like:
SomeNameSapce::IObjPtr o...
Coming from a java background, one of the things I am used to is telling the JVM what the maximum heap size should be. If the running program tries to swallow more than is allowed, and the garbage collector cannot free any more resources, then OutOfMemoryError is thrown and it all goes bang. So setting the maximum heap size is importan...
From a previous question I have seen that the CLR has workstation and server modes for its garbage collector. I know that these can be set from configuration using the gcServer element.
If you don't specify this, does the CLR use some magic to decide for you whether the garbage collector should run in server mode? Something based on C...
Today my colleagues and me have a discussion about the usage of the final keyword in Java to improve the garbage collection.
For example, if you write a method like:
public Double doCalc(final Double value)
{
final Double maxWeight = 1000.0;
final Double totalWeight = maxWeight * value;
return totalWeight;
}
Declaring the ...
I'm trying to find out how much memory my objects take to see how many of them are ending up on the Large Object Heap (which is anything over 85,000 bytes).
Is it as simple as adding 4 for an int, 8 for a long, 4 (or 8 if you're on 64 bit) for any reference types etc for each object, or are there overheads for methods, properties etc.
...
I was wondering if it is possible to tweak the way garbage collector works on JavaMe in order to improve performance somehow(may reducing the number of passages)? I´ve seen some articles about it, but mostly directed Java SE and most of them says GC is highly dependant on the maker. How much would that be.
...
I am running JVM 1.5.0 (Mac OS X Default), and I am monitoring my Java program in the Activity Monitor. I have the following:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Date;
public class MemoryTest {
public static void memoryUsage() {
Sys...
I have multiple xaml based pages stored as children of a canvas on another page. I add and remove the children pages as the application runs. However, pages that are removed from the children collection are still running and respond to keyboard shortcuts. How can I force the older pages to be removed completely?
...
If I understand correctly the .net runtime will always clean up after me. So if I create new objects and I stop referencing them in my code, the runtime will clean up those objects and free the memory they occupied.
Since this is the case why then do some objects need to have a destructor or dispose method? Won’t the runtime clean up af...
I'm looking into why a managed process is using a lot of memory. Is there a way to run GC.Collect(3) from WinDbg, so that I can focus on the actual memory allocation?
...
I'm exploring the possibility of running a Java app on a machine with very large amounts of RAM (anywhere from 300GB to 15TB, probably on an SGI Altix 4700 machine), and I'm curious as to how Java's GC is likely to perform in this scenario.
I've heard that IBM's or JRockit's JVMs may be better suited to this than Sun's. Does anyone kno...
Why is garbage collection required for tail call optimization? Is it because if you allocate memory in a function which you then want to do a tail call on, there'd be no way to do the tail call and regain that memory? (So the stack would have to be saved so that, after the tail call, the memory could be reclaimed.)
...
Do the same best practis rules regarding subscribing/unsubscribing to events apply in asp.net?
I know it might seem like a silly question, but when I think about it, I have never really seen any code where people first subscribe to an event on a page and then unsubscribe later on in the web request.
Example 1:
On a page, in the Page_Lo...