I saw this bit of code in another thread
void foo {
int *n = malloc(sizeof(int));
*n = 10;
n++;
printf("%d", *n);
}
The mistake here is obvious. n isn't being dereferenced.
There is a memory leak.
Let's assume there is a garbage collector working here. The reference count to our initial value of n is zero now because n isn't...
Background
I have a Spring batch program that reads a file (example file I am working with is ~ 4 GB in size), does a small amount of processing on the file, and then writes it off to an Oracle database.
My program uses 1 thread to read the file, and 12 worker threads to do the processing and database pushing.
I am churning lots and ...
So I've been fighting another memory problem in my project for the past week. I tried a couple of memory profilers but nothing gave me insight into what was causing the minor memory leak. The following code turned out to be causing it:
private void DeleteAll( FlowLayoutPanel flp)
{
List<ImageControl> AllList = GetAllList(flp);
L...
The book Learning jQuery says IE has memory leak for the DOM object having a property referencing a function, and the function also referencing the DOM object, thus having a "circular reference", like this:
onload = function() {
var foo = document.getElementById('foo');
foo.onclick = function() { // DOM object foo's onclick pro...
Recently, I asked (and answered) a question on StackOverflow about why a unit test would work when run by itself and then fail sporadically when run with the whole batch of unit tests. See here: http://stackoverflow.com/questions/3072986/sql-server-and-transactionscope-with-msdtc-sporadically-cant-get-connection
Unit tests passing when...
When I debug .net code, how can I know when the garbage collector runs?
I do not wish to control when the garbage collector runs. I only wish to be able to know when it is running. I have some code that is running out of resources. I know that the resources are not being used; I want to know when the GC is running to free them.
Oh, ...
Hi,
I have a .JAR that apparently uses up too much memory, and throws an exception "Java heap space" (or something similar).
So I tried running the .JAR via the CMD like this:
C:\MyFolder>javaw -jar MyJar.jar -Xms64m -Xmx128m
That did not solve the problem. Same error.
Now, when I checked the Processes tab in the windows task manager...
Running a .NET application on Windows Server 2008 x64 with 16GB of RAM. This application needs to fetch and analyze a very large amount of data (about 64GB), and keep it all in memory at one time.
What I expect to see: Process size expands past 16GB to 64GB. Windows uses virtual memory to page the extra data to/from disk as needed. This...
I am trying to reduce the performance/garbage collection costs of logging statements. I want to have lots of logging statements that I could enable for debugging, but also have a way to turn them off for fast production.
I ran a benchmark on calling the following methods:
public static final isLogging = false;
public static logObjs(O...
It's hard to find at design/compile time types that are IDisposable but that are not disposed correctly. What methods are there at runtime to find them?
...
Is outer reference-type object guaranteed to remain valid after assigned to inner object in nested "using" scope?
A x;
{
using (A y = new A())
{
x = y;
}
}
x.foo(); // Is x rock-solid, guaranteed to be still valid here, or is this iffy? i.e. will the call to x.foo() bomb or work only "by chance"?
I'm concerned beca...
In an attempt to close my question on connections remaining open and exceeding the maximum pool, I'm trying tor rewrite the function that is used to connect to our database.
The function exists within a homegrown compiled library. using reflector I can see the code looks like this:
public SqlProvider([Optional, DefaultParameterValue(""...
I have been reading the Garbage Collection chapter from Jeffrey Richter's fine book, "CLR via C#". There, he illustrated an example of how the GC conceptually works (how roots are marked) by referring to a disassembly listing of native code emitted from the JIT compiler. From that example, it occurred to me that nesting reference types i...
I have a PHP script that runs on cron that can take up to an 15 minutes to execute. At regular intervals I have it spitting out memory_get_usage() so I can see what is happening. The first time it tells me my usage I am at 10 megs. When the script finishes I am at 114 megs!
Does PHP do it's garbage collection while the script is running...
I have an .net app that seems to have a memory leak issue(s). The .net service starts out around 100MB of memory, but under load it hits around 400-500MB. Most of my classes don't have unmanaged resources, and the ones that do already implement IDisposable. So my question is would slapping IDisposable on my classes help?
The 4-500 MB is...
I've seem many Android answers that suggest calling the garbage collector in some situations.
Is it a good practice to request the garbage collector in Android before doing a memory-hungry operation? If not, should I only call it if I get an OutOfMemory error?
Are there other things I should use before resorting to the garbage collecto...
I started using Resharper and it indicated when a method could be made static. Would converting a few hundred methods to static methods increase the memory footprint over a large period of time?
...
If you were designing a programming language that features automatic memory management, would using reference counting allow for determinism guarantees that are not possible with a garbage collector?
Would there be a different answer to this question for functional vs. imperative languages?
...
For any application that I have on my Mac, is there a way to tell if it was compiled with GC enabled, or if it's doing manual memory management?
...
I have tried to do this both with GDI+/Invalidate and by using a Line Shape Control. In both cases the memory spirals out of control. To demonstrate, create a windows form application with a timer object which is set to 100ms and enabled and use the following code:
Public Class Form1
Private Y As Integer
Private intDirection As ...