garbage-collection

.NET Garbage Collection behavior (with DataTable obj)

試著忘記壹切 提交于 2020-01-01 15:09:31
问题 I am wondering why after creating a very simple DataTable and then setting it to null does the Garbage Collection not clear out all the memory used by that DataTable. Here is an example. The variable Before should be equal to Removed but it is not. { long Before = 0, After = 0, Removed = 0, Collected = 0; Before = GC.GetTotalMemory(true); DataTable dt = GetSomeDataTableFromSql(); After = GC.GetTotalMemory(true); dt = null; Removed = GC.GetTotalMemory(true); GC.Collect(); Collected = GC

.NET Garbage Collection behavior (with DataTable obj)

孤街浪徒 提交于 2020-01-01 15:09:24
问题 I am wondering why after creating a very simple DataTable and then setting it to null does the Garbage Collection not clear out all the memory used by that DataTable. Here is an example. The variable Before should be equal to Removed but it is not. { long Before = 0, After = 0, Removed = 0, Collected = 0; Before = GC.GetTotalMemory(true); DataTable dt = GetSomeDataTableFromSql(); After = GC.GetTotalMemory(true); dt = null; Removed = GC.GetTotalMemory(true); GC.Collect(); Collected = GC

-gc-sections discards used data

让人想犯罪 __ 提交于 2020-01-01 11:45:17
问题 Using avr-gcc, avr-ld I'm attempting to severely reduce the size of the output file by using fdata-sections -ffunction-sections and gc-sections. When compiled without these options I have an output of ~63KB, and with these options its ~30KB, so it seems great. Unfortunately, after loading and testing the output I notice it doesn't work correctly. Garbage collection seems to have removed far more than I expected, and examining the .map I notice some key data is nonexistent. Any idea on what at

Java: setting a reference to null won't affect the object

限于喜欢 提交于 2020-01-01 11:34:31
问题 I've got a simple question. In this code below, why is s3's value still printed although I set it to null before. It seems gargbage collector won't get called. public class Test { public static void main(String[] args) { String s1 = "abc", s2 = "def", s3 = "ghj"; String sarr[] = {s1, s2, s3}; s3 = null; System.gc(); for(int i = 0; i < sarr.length; i++) { System.out.print(sarr[i] + " "); //prints abc def ghj } } } Any thoughts would be appreciated. 回答1: When you write: // Moved [] to make it

MATLAB takes a long time after last line of a function

孤街浪徒 提交于 2020-01-01 09:05:51
问题 I have a function that's taking a long time to run. When I profile it, I find that over half the time (26 out of 50 seconds) is not accounted for in the line by line timing breakdown, and I can show that the time is spent after the function finishes running but before it returns control by the following method: ts1 = tic; disp ('calling function'); functionCall(args); disp (['control returned to caller - ', num2str(toc(ts1))]); The first line of the function I call is ts2 = tic , and the last

MATLAB takes a long time after last line of a function

拈花ヽ惹草 提交于 2020-01-01 09:05:10
问题 I have a function that's taking a long time to run. When I profile it, I find that over half the time (26 out of 50 seconds) is not accounted for in the line by line timing breakdown, and I can show that the time is spent after the function finishes running but before it returns control by the following method: ts1 = tic; disp ('calling function'); functionCall(args); disp (['control returned to caller - ', num2str(toc(ts1))]); The first line of the function I call is ts2 = tic , and the last

Java heap space Xmx Xms parameters ignored

独自空忆成欢 提交于 2020-01-01 09:01:12
问题 I have a .JAR that apparently uses up too much memory, and throws an exception "Java heap space" (or something similar). So I tried running the .JAR via the CMD like this: C:\MyFolder>javaw -jar MyJar.jar -Xms64m -Xmx128m That did not solve the problem. Same error. Now, when I checked the Processes tab in the windows task manager, I noticed that the process of my jar has a lot less memory than what i asked for (same as running it without the parameters). Why is it ignoring the parameters?

Techniques for causing consistent GC Churn

三世轮回 提交于 2020-01-01 08:59:10
问题 I'm looking to benchmark how something performs while contending with a high amount of ongoing garbage collection. I've previously benchmarked how it behaves in a stable, single-threaded run, and I'd now like to do the same tests in a more stressed JVM; essentially I'd like to have background threads creating and destroying objects at a reasonably consistent pace. I'm looking for suggestions on how to implement a stable yet GC-intensive operation. It needs to accomplish several goals: Spend a

Memory usage when converting methods to static methods

巧了我就是萌 提交于 2020-01-01 08:37:48
问题 I started using Resharper and it indicated when a method could be made static. Would converting a few hundred methods to static methods increase the memory footprint over a large period of time? 回答1: No - Changing to static methods has no effect on memory. The first time a type is referenced (whether static or non-statically), any static members are initialized and static constructors are run. However, if you're just considering switching methods from non-static to static, this will have no

Can jmap -histo trigger full garbage collection?

自作多情 提交于 2020-01-01 06:38:11
问题 We know that jmap -histo:live triggers a full gc in order to determine live objects: Does jmap force garbage collection when the live option is used? Since jmap -histo considers all objects in the heap (those in the young and old generation), my point is, jmap -histo can also trigger a full gc, too. However, I could not encounter a solid documentation about whether jmap -histo may trigger a full gc or not. Can jmap -histo trigger full garbage collection? 回答1: Someone with more JDK experience