garbage-collection

Calling GC.SuppressFinalize() from within a finalizer

故事扮演 提交于 2020-01-13 04:42:29
问题 I was working on a class in which I had to dispose of managed and unmanged resources which looked something like this (only the disposing part, obviously): class MyDisposingExample : IDisposable { public void Dispose() { Dispose(true); } private void Dispose(bool callFromDispose) { // free unmanaged resources here if (callFromDispose) { // free managed resources here GC.SuppressFinalize(this); } } ~MyDisposingExample() { Dispose(false); } } And then a thought occurred to me. Why bother with

Why does C++11 allow for GC? [closed]

六月ゝ 毕业季﹏ 提交于 2020-01-13 03:57:08
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . C++11 allows its implementations to perform (some) garbage collection utilities. Why would the standard allow this? I was always under

Long incidental Young garbage collection pauses

心不动则不痛 提交于 2020-01-13 00:43:27
问题 We tune our GC for minimum "stop-the-world" pauses. Perm and Tenured generations behave well. Young works fine most of the time, and the pauses usually don't exceed 500ms (note [Times: user=0.35 sys=0.02, real=0.06 secs]): {Heap before GC invocations=11603 (full 60): par new generation total 3640320K, used 3325226K [0x0000000600000000, 0x00000006f6e00000, 0x00000006f6e00000) eden space 3235840K, 100% used [0x0000000600000000, 0x00000006c5800000, 0x00000006c5800000) from space 404480K, 22%

how to append gc log

隐身守侯 提交于 2020-01-12 22:13:18
问题 below is gc logging option to write the specific file -verbose:gc -Xloggc:/logs/gc.log OK. Good. but when java app is restarted, old gc log contents in the file disappeared. I hope vm to append gc log to "/logs/gc.log" file. does option for this exist? or i have to write shell script to back up old gc file? 回答1: You are explicitly requesting that the gc data goes to a file named 'gc.log'. You can append the date & pid to the filename to prevent this sort of collision. No mechanism within

how to append gc log

冷暖自知 提交于 2020-01-12 22:11:11
问题 below is gc logging option to write the specific file -verbose:gc -Xloggc:/logs/gc.log OK. Good. but when java app is restarted, old gc log contents in the file disappeared. I hope vm to append gc log to "/logs/gc.log" file. does option for this exist? or i have to write shell script to back up old gc file? 回答1: You are explicitly requesting that the gc data goes to a file named 'gc.log'. You can append the date & pid to the filename to prevent this sort of collision. No mechanism within

How to reduce netty garbage production?

狂风中的少年 提交于 2020-01-12 19:29:27
问题 I have network application that handles about 40k msg/sec written using netty framework and I want to reduce the number of garbage collector calls. While profiling I found that there is significant amount of byte[] instances and I suspect that it comes from this part of code : public class MessageHandler extends SimpleChannelHandler { public void messageReceived(ChannelHandlerContext ctx, final MessageEvent e) { ChannelBuffer message = (ChannelBuffer) e.getMessage(); } } Is it possible to

How to reduce netty garbage production?

那年仲夏 提交于 2020-01-12 19:26:03
问题 I have network application that handles about 40k msg/sec written using netty framework and I want to reduce the number of garbage collector calls. While profiling I found that there is significant amount of byte[] instances and I suspect that it comes from this part of code : public class MessageHandler extends SimpleChannelHandler { public void messageReceived(ChannelHandlerContext ctx, final MessageEvent e) { ChannelBuffer message = (ChannelBuffer) e.getMessage(); } } Is it possible to

Why is OpenJDK 11 Java garbage collector *decreasing* free memory in this sample program?

我与影子孤独终老i 提交于 2020-01-12 18:52:12
问题 When I compile and run the following very simple Java program using OpenJDK 11 (Zulu distribution on Windows 10): public class GCTest { public static void main(String[] args) { System.out.println("Free memory before garbage collection: " + Runtime.getRuntime().freeMemory()); Runtime.getRuntime().gc(); System.out.println("Free memory after garbage collection: " + Runtime.getRuntime().freeMemory()); } } it looks like garbage collection is decreasing the amount of free memory: Free memory before

Best way to track down a memory leak (C#) only visible on one customer's box

只愿长相守 提交于 2020-01-12 06:53:06
问题 What is the best way to track down a memory leak that is only found on one customer's test/release box, and no where else? 回答1: dotTrace3.1 (This question is kinda funny, cause I am tracking a mem leak that isn't present on my machine ...) 回答2: Try a memory profiler like ANTS Profiler. 回答3: If the user has the problem it consistently, take a stackdump and analyse in the standard way 回答4: It's either code, data or configuration. Since you say the code is not faulty 100% of the time, I would

Can we call the Garbage Collector explicitly? [duplicate]

ε祈祈猫儿з 提交于 2020-01-12 06:46:14
问题 This question already has answers here : Why is it bad practice to call System.gc()? (13 answers) Closed 6 years ago . My application has lot of iterations. Till now I haven't faced any memory issues. But from code level I can suspect there are few places, which causes memory leaks and out of memory problem. I am thinking of calling garbage collector manually. Is it good practice to call Garbage Collector manually? 回答1: You can call Garbage collector using: System.gc(); But this does not mean