garbage-collection

What is a softly reachable object?

杀马特。学长 韩版系。学妹 提交于 2020-01-04 05:50:47
问题 I am trying to study the meaning of a soft reference via this 'Soft References in Java' article: https://www.baeldung.com/java-soft-references My problem in understanding this article is that it defines the term "soft reference" via the term "softly reachable object", but I don't know what a "softly reachable object" means. That is, an object in the heap either has a reference to it or doesn't, right? A reference either points to a valid object or is null, right? When does an object become "

Does python garbage-collect at the end of an iteration in a loop?

混江龙づ霸主 提交于 2020-01-04 05:07:42
问题 Please observe this simple code: import random while True: L = list( str(random.random())) Question: if I let this run, will python run out of memory? reason I am asking: First iteration of this loop, a list is created, and 'L' is assigned to represent that list. The next iteration of this loop, another list is created, 'L' is yanked from the previous list and and assigned to the new list. The previous list has lost it reference. Is the previous list going to be garbage collected? if not at

Garbage collection for ValueType wrappers

本小妞迷上赌 提交于 2020-01-04 04:40:14
问题 Quoting from the MSDN Link for ValueType Class In cases where it is necessary for a value type to behave like an object, a wrapper that makes the value type look like a reference object is allocated on the heap, and the value type's value is copied into it. The wrapper is marked so the system knows that it contains a value type. This means when I code like "integerVariable.ToString();" a wrapper-object created allows using this method and similarly all the other methods of System.Object. Is

Managing memory allocated while loading ZipFile

可紊 提交于 2020-01-04 02:22:08
问题 I am attempting to load 69,930 files into a basic text editor. This goes smoothly and after they are all loaded the memory sits at a very cool 130MB. However, during the peak loading time this can hit a maximum of 900MB - 1200MB. The memory is all referencing the Inflater#buf field. This is used only to load the file into the object model, then it is never used again and the bytes can be cleared. Obviously, the extra memory is all cleared by the garbage collector soon after loading - so no

Java - Why forced garbage collection doesn't release memory

倖福魔咒の 提交于 2020-01-04 02:06:13
问题 I am generating a large data structure and write it to hard disk. Afterwards I want to get rid of the object, to reduce the memory consumption. My problem is that after I had forced a garbage collection the amount of used memory is at least as high as it was before garbage collection. I have added a minimal working example what I am doing. DataStructure data = new DateStructure(); data.generateStructure(pathToData); Writer.writeData(data); WeakReference<Object> ref = new WeakReference<Object>

Force the JVM to collect garbage early and reduce system memory used early

我只是一个虾纸丫 提交于 2020-01-04 01:56:28
问题 We operate a Java application that we did not develop. This application uses quite a lot of memory for certain tasks, depending on the data, that is manipulated, up to 4GB. At other times, very little memory is needed, around 300MB. Once the JVM grabs hold of a lot of memory, it takes a very long time until the garbage is collected and even longer until memory is returned back to the operating system. That's a problem for us. What happens is as follows: The JVM needs a lot of memory for a

java heap and thread analysis for memory leak

房东的猫 提交于 2020-01-03 20:59:33
问题 My WebLogic server was configured with 16gb of heap space, but it was 90% used within 1 hour of production usage when most of the users started work. I observed there were several stuck threads whenever this happens. I have captured the heap dump when the heap was approx 10% free. How do I inspect the heap dump to find out the memory leak, or process, codes which is causing this issue. I have tried to understand the memory leak, running tools like JMap and Eclipse MAT, but it maybe due to

java heap and thread analysis for memory leak

廉价感情. 提交于 2020-01-03 20:59:07
问题 My WebLogic server was configured with 16gb of heap space, but it was 90% used within 1 hour of production usage when most of the users started work. I observed there were several stuck threads whenever this happens. I have captured the heap dump when the heap was approx 10% free. How do I inspect the heap dump to find out the memory leak, or process, codes which is causing this issue. I have tried to understand the memory leak, running tools like JMap and Eclipse MAT, but it maybe due to

How to make object in List eligible for garbage collection?

只愿长相守 提交于 2020-01-03 20:02:40
问题 I understand that when an object is added to a List, the List retains a reference to that object based on answer from this question Is this java Object eligible for garbage collection in List How then how do you make the object in the List eligible for garbage collection so that it's removed from the heap and not taking up memory? I ask because in JavaFX, a Vboxs getChildren method returns observable list containing the children nodes of the vbox. If a UI element is removed but not eligible

Python threading.Thread, scopes and garbage collection

那年仲夏 提交于 2020-01-03 18:54:08
问题 Say I derive from threading.Thread: from threading import Thread class Worker(Thread): def start(self): self.running = True Thread.start(self) def terminate(self): self.running = False self.join() def run(self): import time while self.running: print "running" time.sleep(1) Any instance of this class with the thread being started must have it's thread actively terminated before it can get garbage collected (the thread holds a reference itself). So this is a problem, because it completely