12,274 questions
2
votes
1
answer
80
views
Freeing memory to OS after heavy function without forcing GC
I have a Python function that consumes a large amount of memory. When the function finishes, I want to release the memory and return the freed pages to the operating system by calling malloc_trim(0).
...
24
votes
2
answers
2k
views
Why do JavaScript Websocket objects not get destroyed when they go out of scope?
In JavaScript, when you do something like this,
function connect() {
var ws = new WebSocket(url);
ws.onmessage = function(e) {
window.alert(e.data);
};
}
it will work. But why ...
0
votes
2
answers
170
views
What is the difference between the Heap size and the Private Bytes size?
I have a .Net 4.7 application (WPF) whose memory consumption increases to 5.785 GB in private bytes, but the heap bytes are 4.260 GB, as shown in the figure taken by Process-Explorer:
If I run GC ...
0
votes
1
answer
152
views
Why do Images leave giant piles of RAM behind them? [closed]
I am currently working on a .NET 9 WinForms program that contains an ImageViewer, which is a seperate window where you can scroll through a series of images.
My problem is that even after closing the ...
2
votes
1
answer
171
views
Does JavaScript object destructuring allocate a new object?
In the following JavaScript, does the object destructuring that follows the creation of target create a new (temporary) object that has to be garbage collected? In other words, are there two objects ...
1
vote
1
answer
81
views
Under what circumstances can a write to a Haskell unsafeThaw-ed array/vector result in a segfault (via lost GC root)?
This question tries to collect the full picture if/when a stale object reference can happen from an old-gen (immutable) array referring a newer-gen object, from fragments of information.
Preface: was ...
0
votes
0
answers
47
views
H2O-3 Calling a lot of GC calls in java when trying to load CSV file with 16M rows
I am using h2o-3 java repo to load this frame but have been running into memory issues with constant GC pressure.
The actual frame size is 3.31 GB as per h2o logs, but the peak JVM usage comes to be ...
2
votes
1
answer
89
views
How can I tie a coroutine's lifetime to the lifetime of an object?
I have some code similar to this:
class Foo {
var x = 0
init {
GlobalScope.launch {
while (true) {
delay(1000)
x += 1
}...
2
votes
1
answer
176
views
Native objects do not trigger garbage collection
I am trying to do some linear algebra in Kotlin/JVM and I have two ways of doing it:
Using Apache commons-math, which implements matrix multiplication purely on the JVM
Using OpenCV's Mat class and ...
0
votes
2
answers
108
views
Is there a better way to simulate work in unit tests? [closed]
My company is finally starting to introduce unit tests.
While going through some of the new tests, I came across this one:
[Test]
public void GetCorrectTimeoutInfoFromTimeSpan()
{
// Arrange
...
2
votes
2
answers
577
views
How to release memory of intermediate Python-Polars DataFrames in a large dependency graph?
I am performing operations on a directed acyclic graph (DAG) of DataFrames using Polars (eager API).
Here’s a simplified example of my workflow:
Read parquet files into df1.
Use df1 to create df2 and ...
1
vote
1
answer
59
views
Looking for simple garbage collector load test
I'm looking for some code or some benchmark to roughly asses the pause times or cpu load caused by some GC in order to get some rough estimate how efficient it is. I just want to see whether some GC ...
1
vote
0
answers
96
views
System.Windows.Forms's WebBrowser is garbage collected differently in .NET Framework and Core
I'm trying to migrate our application from .NET Framework to .NET Core. In one of our tests, an object of type ZWebBrowser : System.Windows.Forms.WebBrowser is not garbage collected correctly, due to ...
1
vote
2
answers
95
views
How can I manually trigger garbage collection from an asynchronous javascript function?
I'm calling global.gc() in some unit tests, but for some reason it only seems to have any impact when called synchronously. If I call it asynchronously, I never seem to get a cleanup callback in my ...
0
votes
1
answer
150
views
Java 17: Metaspace (data) allocation failure in GC log without a java.lang.OutOfMemoryError: Metaspace
I am seeing the below in the GC log before the JVM pauses for several minutes after which it gets restarted externally.
[2025-07-18T18:08:42.605-0600][info][gc,metaspace,freelist,oom] Metaspace (data) ...
3
votes
0
answers
140
views
Memory usage accumulates in simple loop until PC crashes
I have recently experienced major crashes on my computer after executing some Python code of mine. My PC would freeze and sometimes show a bluescreen after a few rounds of a seemingly unproblematic ...
0
votes
1
answer
105
views
Vue 3: Detached <video> elements not garbage collected after src change
I'm working with a Vue 3 component that plays videos using the native tag. I dynamically change the src of the video based on a prop (videoName) and I need to avoid memory leaks.
Despite cleaning up ...
1
vote
1
answer
131
views
Garbage collector or flag/option to force complete collection (no matter how long it takes)
We are trying to implement memory leak regression tests.
For this it would be very useful to have a deterministic garbage collector that takes as much time as needed, but collects everything that is ...
0
votes
1
answer
178
views
How do I configure garbage collection for a ASP.NET 4.8 IIS application pool?
I'm trying to fine tune performance/memory usage of a ASP.NET 4.8 web application in IIS. I did all the measurements and determined that I'd like to sacrifice a bit of performance for lower memory ...
1
vote
2
answers
130
views
Why read barrier cannot resolve the "Stop The World" in the ZGC garbage collector?
I've seen some similar posts, but I did not found a exact answer. So please remember that this question is about root marks and read barriers.
For garbage collectors, such as ZGC, the Mark phase still ...
0
votes
0
answers
38
views
Understand .NET memory usage pattern in docker - GC vs RSS vs Cache
I am running a .NET 8 application inside a Linux container on Kubernetes and monitoring it with Grafana. The pod has a memory request and limit set to 256 MiB.
I see that the memory is at 90+ percent ...
0
votes
1
answer
57
views
Does DependentHandle need to be disposed?
Must I call Dispose when I'm done with a DependentHandle? Or will the resources get cleaned up at the next garbage collection? (Is the InternalFree call essential, to notify the GC that the handle is ...
0
votes
0
answers
23
views
Garbage Collection discrepancy
I am debugging performance issues with a live application running on AWS Fargate.
I've collected CPU profiling data using the inspector by connecting to a live instance.
I've also collected ...
0
votes
0
answers
53
views
Native Memory Tracking GC stats
We have a java app that runs on openjdk version "11.0.18" 2023-01-17 LTS and it started swapping for a few weeks.
When running jcmd <PID> VM.native_memory, we get something like this:
...
1
vote
1
answer
69
views
Python/TensorFlow: Persistent RAM increase in a long-running loop despite clear_session and gc.collect
I'm running a Python script on a VPS in a continuous loop. The script fetches stock data with yfinance, then trains a new TensorFlow/Keras model for each stock.
Problem: The process's RAM usage ...
1
vote
2
answers
95
views
Numpy delete() function increases memory usage
I am using np.delete(), to drop a specific band from my ndarray. However, while profiling the memory usage with memory profiler, I noticed that after using np.delete, the memory usage doubles, even ...
4
votes
1
answer
145
views
Go GC doesn't collect dead weak pointers
I am trying to use weak pointers introduced in go1.24 to build a system in which weak pointers can be passed as interfaces. The problem is that weak.Pointer doesn't follow the same interface as the ...
3
votes
1
answer
106
views
How do I minimize C# memory allocations / GC churn with UDP sockets?
I'm receiving data over UDP in a C# application, using socket.ReceiveFrom calls:
byte[] buffer = new byte[1024];
EndPoint remoteEndPoint;
...
int byteCount = socket.ReceiveFrom(buffer, SocketFlags....
1
vote
1
answer
369
views
Why does .NET NativeAOT perform worse than the JIT mode in GC and multi-threaded synchronous concurrent environments?
Recently, I have added.net NativeAOT support to the local embedding mode of the client and in-memory database of the AutoCSer RPC framework I developed.
Originally, it was expected that the AOT mode ...
1
vote
1
answer
90
views
How can I protect a variable from the garbage collector in Julia when using ccall?
I am having trouble protecting a buffer from being garbage collected while using my own MPI bindings in Julia. In particular I am using this function:
function Recv(buf::Ref{T}, count::C_int, datatype:...
2
votes
0
answers
73
views
How does "old space" differ from "old generation" in Java?
I'm trying to interpret the following output of the jstat command:
$ jstat -gcoldcapacity 57208
OGCMN OGCMX OGC OC YGC FGC FGCT CGC CGCT GCT
...
2
votes
0
answers
84
views
How does Python's garbage collector handle circular references in custom objects?
I'm working with complex data structures involving custom classes that reference each other.
I’m aware that Python uses reference counting, but also has a cyclic garbage collector for circular ...
2
votes
1
answer
157
views
PHP not releasing memory of variable
I have a server which has 2 PHP scripts that run continuously in the background. One of those scripts, for some reason, is not releasing memory and it's making the other script fail because eventually ...
-1
votes
1
answer
157
views
Why can't JVM trigger GC when the system is idle but can only trigger GC when object allocation fails? [closed]
Whether it is G1, ZGC or SGC, it seems that GC can only be triggered when the allocation of a new object fails. If I do not allocate objects, then my space will always be occupied, even if my system ...
0
votes
0
answers
66
views
What's funny about sparcv9 processors' or Solaris' stack handling?
I am maintaining Professor David Turner's interpreter for Miranda
and it now works on aarch, amd, arm, chrp, evbarm, loongarch, mips, powerpc, riscv and x86, 32-bit and 64-bit, big-endian and little-...
1
vote
4
answers
149
views
Why doesn't JavaScript's garbage collector clean up global variables? [closed]
I've been reading an article about memory management in JavaScript, and it says that the global scope objects don't get cleaned from the memory.
If a global variable is not being referenced anywhere ...
2
votes
0
answers
262
views
What might cause this improvement in Garbage Collector performance in .NET 7.0 (making it better than .NET 8.0 and 9.0) (C#, Linux)
We have a large app written in C# (a multiplayer game) with around 10 million objects on the heap. However, the effect described in this question can be observed even in a simple test app with a ...
2
votes
0
answers
55
views
JS HTMLImageElement and garbage collection
Am I required to hold ref to HTMLImageElement to prevent it from being gc'ed befor its load/error events will be fired?
for example:
/**
* @param { string[] } urls
* @returns { Promise<...
0
votes
1
answer
98
views
How does Java handle weak reference with cycle?
Suppose I have objects A and B which strong/regular reference each others, forming a reference cycle. The path from A to the GC root is dominated by a weak reference (represented by the dashed arrow ...
0
votes
2
answers
88
views
Is getting a span to a fixed buffer GC compact safe? [duplicate]
Considering this .net standard 2.1 compliant code
public unsafe struct CharacterStorage
{
public const int Capacity = 20;
fixed char Characters[Capacity];
public Span<char> GetSpan(...
1
vote
0
answers
22
views
Why doesn't HttpClient.Send trigger CA2000 (not disposed)
Send or SendAsync return HttpResponseMessage, which implements IDisposable in order to cleanup the HttpContent stream, from what I know. Why doesn't CA2000 flag undisposed instances of the response ...
0
votes
1
answer
97
views
Change garbage collector in Payara Docker image
I need to change a default garbage collector in Payara server(version 2025, jdk 21) docker image. I tried either preboot or postboot commands with configuration below, still not changing.
These are ...
0
votes
0
answers
33
views
Pygame surfaces less than 256 by 256 pixel don't seem to be collected by the GC (Windows 11, python 3.11.4)
When I run this script, the task manager shows that when the cache list if full the program uses around 2GB and when popping all elements it goes down to about 20MB.
But, if the surfaces are 255 by ...
0
votes
0
answers
23
views
WPA, symptoms with intermittently high wait times in certain threads
C# Program is running A thread.
A Thread is using ThreadSleep(1) during a while statement iteration.
Of course, I set TimeBeginPeriod to 1.
On average, one cycle is completed after 3-5ms, but ...
0
votes
1
answer
100
views
Does the Dispose pattern without a finalizer make any sense?
Given this code in the dispose-pattern from msdn
public class DisposableResourceHolder : IDisposable {
private SafeHandle resource; // handle to a resource
public DisposableResourceHolder() {...
0
votes
3
answers
142
views
Is it wrong to declare simple variables like int, double, bool, var, String, List inside callback function?
Is it wrong to declare simple variables like int, double, bool, var, String, List inside callback function? (Which is generally nested within the build method.)
For, example, I have a ...
0
votes
0
answers
141
views
KDB+ Process Not Releasing Memory After Garbage Collection .Q.gc[] and Table Clearing
I am encountering an issue where memory is not being released back to the OS, even after clearing large in-memory tables and running .Q.gc[]. Despite multiple attempts, the process continues to ...
0
votes
0
answers
42
views
Fatal Python error: GC object already tracked when invoking set constructor
I have following Python2 function in a big Python-Cython project (print statements added for debugging):
import gc
def e_closure (startstate):
"""Return all states reachable from ...
1
vote
1
answer
65
views
What happens if I don't call .join on my Ruby threads?
I have an API that returns handles to background processes. These handles themselves have some threads as instance variables. I want to avoid forcing the user to call an explicit cleanup method to ...
0
votes
0
answers
47
views
Trying to understand PHP Garbage Collection [duplicate]
Forgive my ignorance but I've not played around with PHP's garbage collection before. Specifically, I'm running a CakePHP 5.x Command Script and running into memory exhausted issues.
As a test to see ...