garbage-collection

Can we call the Garbage Collector explicitly? [duplicate]

故事扮演 提交于 2020-01-12 06:46:11
问题 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

Java GC: top object classes promoted (by size)?

本小妞迷上赌 提交于 2020-01-12 05:35:08
问题 Please let me know what is the best way to determine composition of young generation memory promoted to old generation, after each young GC event? Ideally I would like to know class names which are responsible say, for 80% of heap in each "young gen -> old gen" promotion chunk; Example: I have 600M young gen, each tenure promotes 6M; I want to know which objects compose this 6M. Thank you. 回答1: There is no easy way to do this, however, I have recently been analyzing memory performance of

C# not releasing memory after task complete

天大地大妈咪最大 提交于 2020-01-12 02:25:12
问题 The following code is a simplified example of an issue I am seeing. This application consumes approx 4GB of memory before throwing an exception as the dictionary is too big. class Program { static void Main(string[] args) { Program program = new Program(); while(true) { program.Method(); Console.ReadLine(); } } public void Method() { WasteOfMemory memory = new WasteOfMemory(); Task tast = new Task(memory.WasteMemory); tast.Start(); } } public class WasteOfMemory { public void WasteMemory() {

Java GC : Why Two Survivor Spaces [duplicate]

孤者浪人 提交于 2020-01-11 19:39:09
问题 This question already has answers here : Java GC: why two survivor regions? (8 answers) Closed 5 years ago . In most of the tutorials online, we can see that they show there are two survivor spaces in GC. What is the need to have two survivor spaces when we can actually have only one? What are the impacts on performance by having two survivor spaces? 回答1: The reason is, you are guessing it right, performance. Let me first explain why the survivor spaces exist at all. There are two primary

Clarifications regarding weak references in actionscript listeners

旧时模样 提交于 2020-01-11 12:36:11
问题 I understand how weak references work, but I am bit confused regarding it's use in actionscript event listeners. Consider the example below: public class Rectangle extends MovieClip { public function Rectangle() { var screen:Shape=new Shape(); screen.addEventListener(MouseEvent.MOUSE_OUT, new Foo().listen, false, 0, true); addChild(screen); } } public class Foo extends MovieClip { public function listen(e:MouseEvent):void { trace("tracing"); } } Now here, since there is only a weak reference

GC overhead of Optional<T> in Java

这一生的挚爱 提交于 2020-01-11 09:50:08
问题 We all know that every object allocated in Java adds a weight into future garbage collection cycles, and Optional<T> objects are no different. We use these objects frequently to wrap nullable, which leads to safer code, but at what cost? Does anyone have information on what kind of additional GC pressure optional objects add vs. simply returning nulls and what kind of impact this has on performance in high-throughput systems? 回答1: We all know that every object allocated in Java adds a weight

Android and Java: Reduce memory usage on a service loop

ぐ巨炮叔叔 提交于 2020-01-11 07:20:29
问题 I have an Android Service which updates a notification every second using this Thread (comments are not really relevant): thread = new Thread() { @Override public void run() { // Preparando la notificación de Swap NotificationCompat.Builder notificationSwap = new NotificationCompat.Builder(context) .setSmallIcon(android.R.drawable.ic_dialog_info) .setContentTitle("Notificator:"); NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

Viewing garbage collection history in c# (VS2015)

ε祈祈猫儿з 提交于 2020-01-11 05:36:26
问题 A unforeseen and unanticipated amount of garbage collection activity is shown in the 'Process Memory' graph when I run my application which makes me want to know where in the program is the garbage generated as I don't feel that I have any memory leaks in the program. Can someone please tell me if there is a way to view the parts (or lines) of my code where garbage is generated? Thanks in advance. 回答1: Pretty much any memory profiler will show this info. Just look for a list of "Dead objects"

Unable to open another excel file (when one Excel is opened by .net)

我只是一个虾纸丫 提交于 2020-01-11 04:43:38
问题 I have designed a .net application which will open an Excel file at the time of login and use it to print a report. It will be closed while logging out the user. I set visible to false for Excel file, so that user doesn't know about the background process. But if anybody opens any other Excel file during this time, my report Excel file becomes visible and the Excel object is collapsed. I have to go to task manager and kill the all open Excel instances to fix this. Code: Private Sub OK_Click

TaskScheduler.UnobservedTaskException never gets called

只谈情不闲聊 提交于 2020-01-10 13:52:28
问题 Based on my research, I have learned the following: TaskScheduler.UnobservedTaskException must wait for the task to be garbage collected before that task's unobserved exception will bubble up to the UnobservedTaskException event. If you're using Task.Wait() , it'll never get called anyway, because you're blocking on an impending result from the Task, hence the exception will be thrown on Task.Wait() rather than bubble up to the UnobservedException event. Calling GC.Collect() manually is