Questions tagged [garbage-collection]
Garbage collection (GC) is a form of automatic memory management which attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program.
12,115
questions
0
votes
1
answer
42
views
Why does the removeFirst method of a LinkedList help the garbage collector by unlinking the first node? [duplicate]
The code below is a method that removes the first node from a linked list.
public E removeFirst() {
final Node<E> f = first;
if (f == null)
throw new NoSuchElementException();
...
0
votes
0
answers
50
views
How to tell how close we are to a GC for java processes?
I'm currently implementing some revisions in my ongoing project and I'm curious about their potential impact on garbage collection metrics. Specifically, I'm interested in continuing a custom paradigm ...
0
votes
1
answer
25
views
How are memory allocations handled in "bytecode based" languages?
As far as I understand any program written in let's say c# the source is first compiled to an intermediate language, which is then jitted by the clr to corresponding machine instructions.
But what ...
2
votes
0
answers
22
views
Does Marshal.StructureToPtr<T>() allocate objects on managed heap?
I'm trying to reduce the memory allocations to reuduce Garbage Collection time in my application.
When analyzing my application for memory allocations, the VS2022 Performance Profiler tells me that ...
1
vote
1
answer
30
views
TypeScript / JavaScript - Will this WeakMap 'hack' work as I intend?
Normally, if I want to keep an array full of all created instances of a class, I keep a reference to each instance in my array, thus keeping the instances from being garbage collected when the ...
0
votes
2
answers
55
views
How to use FinalizationRegistry to clear interval inside a class constructor when object is destroyed?
I have this code created with help from ChatGPT:
class Thing {
#intervalId;
#finalizationRegistry;
constructor() {
console.log('constructor()');
let count = 0;
this....
1
vote
1
answer
39
views
How can I see that FinalizationRegistry indeed invokes the given callback when an object gets consumed by the garbage collector?
In the latest Chrome browser 119.0.6045.159 (Official Build) (64-bit) in December, 2023, on Windows 10, I run the following snippet in the Chrome DEV console, and I expect to see the Garbage collected ...
-1
votes
1
answer
31
views
Does the native executable that is created by graalvm compiler includes memory management and GC?
I have been exploring graalvm and couldnt find an answer for this. Since the native executable that is created by graalvm compiler can run on any VM without Graalvm or JVM, what takes care of the ...
0
votes
0
answers
145
views
+500
Increase in Eden Space and Old Gen peak values
After Java 17 upgrade, JVM heap memory started to increase. When we check the memory metrics, sizes of the Eden Space and the Old Generation fluctuating and peak values are increasing.
There seems no ...
0
votes
0
answers
13
views
how to dump the heap total new in node 16
Today I monitor the node(version 16) application and found the heap total new momory takes 100MB+ memory, my application is very small and simple. I have read the source code and did not found where ...
0
votes
0
answers
44
views
Will a struct be garbage collected if there's no references to the struct but the struct contains a pointer to a global object?
As the title says, say if a struct A contains a pointer to a global object globalB:
type struct B {
// fields of B
}
type struct A {
pb *B
}
var globalB B
func newA() *A {
a := &A{
pb:...
0
votes
2
answers
44
views
Java Garbage Collector - CMS vs G1
I have a question about a garbage collector.
I have set 24GB for my Xms and Xmx, but the problem I'm facing is that I see that the full heap size is never used - the garbage collector seems to run ...
-1
votes
0
answers
27
views
Value at an address keeps changing during execution of a program in C# - unsafe code
I wanted to implement Memory Efficient Double Linked List in C# and quickly found out that ^(XOR) operation can't be done directly on reference objects. So, I decided to write unsafe code. Now, I have ...
0
votes
2
answers
62
views
Does Parallel GC support shrinking heap size?
I got two conflicting answers regarding this question from two places.
The baeldung article says
For example, Parallel GC doesn’t release unused memory back to the OS readily.
So I think ...
0
votes
1
answer
48
views
Why int64 array is so big in TimerThread
I'm investigating OutOfMemoryException in 32bit process,
the following stats has drawn my attention (large int64 array):
!dumpheap -stat
........
707b251c 3 692500 System.Int64[]
6fa6b038 ...
1
vote
1
answer
45
views
Can I rely on garbage collector to close asynchronous database connections in Python?
My team is working on an asynchronous HTTP web server implemented in Python (CPython 3.11 to be exact). We're using Redis for data storage and connect to it with the help of the redis-py library. ...
-2
votes
0
answers
17
views
In Boehm GC's Generational Collection, how to obtain the address of the new generation pages
I am using Boehm GC (ver. 8.2.2) on the Linux operating system.
The language I am using is C.
Objective:
I would like to output the address of the new generation pages each time a minor GC is ...
0
votes
0
answers
25
views
.Net stuttering while freeing up memory
I'm working on a DirectX 12 based app in c# with .Net Framework 4.8, which interface to DirectX using a c++/cli project.
Regardless of the context, I'm noticing heavy stuttering (the app freeze for ...
0
votes
0
answers
45
views
How to prevent panic in Go while stack expands and encounters invalid address in unsafe.Pointer?
I am developing my own interpreter for my custom programming languages that has a couple of types (integers, strings, arrays, functions...). So, I had a dillema how to represent those types ...
0
votes
1
answer
44
views
Why isn't RSS reduced when System.gc() for parallel, but for G1 is?
I'm using Java 17. I have a container with 2GB and run the following Java program:
import java.util.*;
public class Main{
public static Map<byte[], byte[]> m = new HashMap<>();
...
0
votes
0
answers
30
views
Lua GC is not collecting automatically
I'm kinda new to lua although I've already used this language other times and I've read quite a bit about it. Now I'm using it for the second time as my scripting language for a C++11 project. The ...
0
votes
0
answers
56
views
a disproportionate amount of dead objects were detected
I made a simple example to showcase the problem. I have a blazor project with a page that call a function:
<button @onclick='(() => TestMemory())'>Insert Memory</button>
<h3>...
0
votes
2
answers
65
views
How immutable objects' memory cleared?
I have some questions-
As string constant pool is present in the heap memory and GC collects garbage from heap memory.
Does it cleans the string constant pool as well, according to my info it does ...
0
votes
1
answer
59
views
Is the GC.KeepAlive official example valid?
I'm looking at the official example of the GC.KeepAlive method. But I don't fully understand why the GC.KeepAlive is necessary there.
The GC collects all the objects that have no more references. To ...
1
vote
1
answer
85
views
When should I NOT call GC.SuppressFinalize(this) in Dispose?
I have a simple class like this that implements IDisposable and so it's hit by a CA1816: Call GC.SuppressFinalize correctly:
public class A : IDisposable
{
// ...
int foo
public A()
{
...
-1
votes
1
answer
65
views
how to control jvm heap usage rate to stay below 80% as much as possible?
Our springboot app is used for get large data and compress it. so it always needs large memory.But customer's Prometheus always monitor it and send alarm to us heap memory usage rate exceeds 80%....
0
votes
0
answers
71
views
Can't install node gc-stats
I have been trying to install (for the past 18 hours) npm i gc-stats in a node.js version 18.15.0 and windows but it gives me the next error:
PS C:\Users\fdesantiago\Documents\test> npm i gc-stats
...
1
vote
0
answers
69
views
In C#, Why Is A Stack of Structs Referencing Reference Types Slower to Push Than Structs Containing Value Types?
If I have a Stack, I would have expected that a mystack.Push() would be about the same performance for T being a struct, and maybe a little slower for T being a reference type. When I benchmark this ...
0
votes
0
answers
48
views
Should I keep the C# reference to an NSData object around until I know for sure that an underlying native call in iOS has finished using it or not?
I'm dealing with C# bindings to iOS and I was curious about certain aspects of parameter-passing. Assume we have the following piece of code:
public void BeginNativeCallFromCsharpToIOS(...
-1
votes
0
answers
35
views
Will nodejs garbage collector free the allocated memory?
I am working on a nestjs application.
As we know, NestJS has its dependency injection.
If i create a service(lets call it ExternalServicrClient) using the Nesjs DI, and that service is a singleton,
...
0
votes
0
answers
38
views
PySpark GC issue - job taking more than 3 hrs to finish
I'm running spark application with only 5GB uncompressed csv files using 1 node 16gb machine, facing very high GC time, actual computation will take only 15 mins and 3hr+ for GC, what could be the ...
0
votes
1
answer
48
views
Overriden method finalize() isn't called for all of the garbage objects [closed]
I have a class Tank that has an overridden method finalize(), which prints the message:
@Override
protected void finalize() {
if (full) { // -full : boolean
System.out.println("Error:...
0
votes
0
answers
35
views
Application running out of memory due to apache kafka metric objects while using kafkaProducer
We try to send 1000s of messages to a kafka-topic using kafkaProducer(org.apache.kafka.clients.producer.KafkaProducer) objects on our tomcat application. Lately we have been observing an issue with ...
0
votes
3
answers
99
views
C# - Correct way to pass parameters to avoid GC stutters? [closed]
(I found some related questions, but they were not exactly same or a decade old.)
So, are parameters in C# passed as value or references.
say I do,
static void main()
{
string name = "hello ...
0
votes
0
answers
14
views
The node triggered garbage collection event through not reached the max size limit
I am using this command to startup the node.js (v16.20.2) application:
node --max-old-space-size=256 --max-semi-space-size=128 --trace-gc ./bin/server-express.js >> ws.log 2>&1 &
...
0
votes
0
answers
123
views
How JVM handles direct buffers
I have a Java application built on the Quarkus framework. Immediately after deploying the application, it consumes a significant amount of direct buffer memory. As illustrated in the screenshot, the ...
0
votes
1
answer
42
views
How to check what the garbage collecter is collecting
I am an Android developer. I got this message repeatedly. This message is not error just information. I want to know what the garbage collector is collecting (for optimization my app performance)
15:...
0
votes
1
answer
54
views
Separate ClassLoader to Help Garbage Collection
Consider a java library consisting of "setup code" as opposed to run-time code.
The setup code can contain many classes defining menus with tables of options.
During the run-time of the ...
1
vote
0
answers
32
views
Find contributors to garbage in Java 21 or what replaces -XX:+PrintClassHistogram(Before|After)FullGC
With Java 8 I occasionally used both, -XX:+PrintClassHistogramBeforeFullGC and -XX:+PrintClassHistogramAfterFullGC to get an impression about which classes contribute most to the garbage to be ...
0
votes
1
answer
46
views
Spring Boot Application throws Out of Memory Exception when multiple requests are sent
I have a Spring Boot application with multiple REST endpoints. I'm attempting to send around 50 requests to a basic health check endpoint. However, this is causing an OutOfMemoryError. I tried ...
0
votes
0
answers
14
views
Is there a difference in memory management outcomes between using an object as an argument or a spread copy of the object?
Is there a difference between how garbage collection works when an object is passed directly as an argument to a function or the spread copy of the object is passed instead?
const myObject = {
a: 1
}
...
0
votes
0
answers
41
views
Do i need to build my web app using .net framework 4.5 and above if <performanceScenario value="HighDensityWebHosting" /> need to be used?
from documentation it mentioned required a .net framework 4.5. Does that mean i just need to install .net framework 4.5 in my hosting server ? Or i also need to rebuild my web application with .net 4....
1
vote
3
answers
56
views
Is there a way to store a MemoryHandle exclusively in unmanaged memory?
I have a method which takes in a Memory<T> object. I want to pin it, and store a pointer to it exclusively in unmanaged memory. I know I can get this pinned pointer by using memory.Pin() to ...
1
vote
1
answer
44
views
C# Create separate Garbage Collector per thread
I'm planning on creating a real-time audio editing and sequencing application in C# using mainly the cscore library for handling the audio on the backend, and then Avalonia for the frontend (using ...
1
vote
0
answers
52
views
ConditionalWeakTable works differently in .Net 7.0 and .Net Framework 4.8? [duplicate]
Here's something that is really mind boggling. I discover that ConditionalWeakTable is working differently in .Net 7.0 and .Net Framework 4.8.
I get the code straight from here:
public class Program
{
...
1
vote
0
answers
61
views
Collect the stop-the-world duration in a concurrent GC (G1)
So currently Im using ManagementFactory.getGarbageCollectorMXBeans() but the young GC in G1 only includes 2 steps that are actually STW.
From the duration (and I might be wrong here) I gather the time ...
0
votes
1
answer
39
views
Relaunch Fargate Task Before Stop the World Garbage Collection
I have an ECS service with multiple tasks running a Java web application. We have a memory leak which causes the memory on each task to increase over time. When the memory usage gets to about 90%, ...
1
vote
1
answer
150
views
Which JVM dereferenced object cleanup implementation works best?
Assuming an object K is associated with a scarce system resource (e.g. binded to an open port on localhost UDP, of which only 65535 per machine is available). A JVM application is required to create ...
0
votes
0
answers
38
views
In Java 9+ with Scala, how to make a Cleanable that can be triggered by `System.gc()`
Considering the following example in Scala 2.13.12 & Java 11:
class CleanableSpike extends AnyFunSpec {
import CleanableSpike._
it("triggered by GC") {
var v = Dummy(inc)
...
1
vote
1
answer
61
views
.NET 7 System.OutOfMemoryExceptions
We have recently migrated our .NET 5 application to .NET 7 and also upgraded our UI framework from standard MVC to Vue 3. We are fully up and running with our code deployed. Just about a week after ...