garbage-collection

Garbage collector issues on spidermonkey… JS_AnchorPtr()?

安稳与你 提交于 2019-12-31 02:44:07
问题 I've rolled my own javascript server side language called bondi. Just recently upgraded to the new spider monkey. Now that JS enter local roots and leave local roots function is gone/useless from the 1.8.5 api, is it enough to just use anchor pointer( JS_AnchorPtr(varname) ) at the end of your function calls to make sure the compiler isn't removing references to keep the garbage collector happy? I've been testing it by removing all my references to JS_EnterLocalRootScope (see here) / Leave

Smart Garbage Collection?

眉间皱痕 提交于 2019-12-31 02:15:08
问题 You can garbage collect in Java simply by calling System.gc() but sometimes this "stalls" the application. Is it a bad idea to garbage collect like this and avoid stalls: new Thread(new Runnable() { public void run() { System.gc(); } }).start(); Or might this lead to even more problems? 回答1: Yes, most times it is a very bad idea to call System.gc(). There are exceptions but they are few and it is mostly better to spend the time making sure you are not doing things that hurt performance in a

Clearing a private collection or setting it to null?

假装没事ソ 提交于 2019-12-30 18:26:16
问题 I have a mutable class which has a private List<T> field inside. In the Reset() method of my class, should I clear the list using its Clear() method or just assign its field a new list? Note that the list is not public and is only used by the class itself. So assigning a new list should make the old one unreachable. Since the Clear() method is an O(n) operation, I wonder what is the downside of just assigning a new list over it. 回答1: The only downside I can think of is if you need to use the

Is there a way to do a WeakList or WeakCollection (like WeakReference) in CLR?

笑着哭i 提交于 2019-12-30 16:24:01
问题 Using a List<WeakReference> will not work as I want. What I want is for WeakReferences to be automatically removed from the list whenever the object they reference is garbage collected. ConditionalWeakTable<TKey,TValue> does not satisfy me either, because although its keys and values are weakly referenced and collectable, you cannot enumerate them! 回答1: I agree that implementing a WeakList<T> is possible, but I don't think it's exactly easy . You're welcome to use my implementation here. The

garbage collection issue in young generation [closed]

♀尐吖头ヾ 提交于 2019-12-30 14:59:05
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . When Eden space is young generation is full, minor GC will be triggered. And in the minor GC process, non-free objects in Eden and one source Survivor space will be copied to another destination Survivor space.

Minimizing page faults (and TLB faults) while “walking” a large graph

你离开我真会死。 提交于 2019-12-30 13:00:08
问题 Problem (think of the mark phase of a GC) I have a graph of “objects” that I need to walk, visiting all objects. I can store in each object if it has been visited. All the objects are stored in memory and linked together using normal pointers. The objects are not all the same size. Sometimes there is not enough ram in the system to hold all the objects in memory at the same time, and I wish to avoid “page thrashing”. I also wish to avoid TLB faults Other times, there is more than enough ram.

Actionscript memory management, garbage collection

我与影子孤独终老i 提交于 2019-12-30 11:18:10
问题 This blog (and others) state that you should set object references to null inside your dispose() methods when cleaning up objects. However, Actionscript 3 (with Flash Player 9) uses mark and sweep to clear out circular references for you. So I am wondering: is there really any reason to null out your object references? 回答1: I never do - as long as you do the obvious: Break all reference to the object (remove from arrays, set variables storing the object to null, remove from display list)

.NET garbage collection not working properly here?

扶醉桌前 提交于 2019-12-30 10:37:20
问题 We had an image conversion script running on .NET 4.0, IIS 7, ASP.NET, 4 GB server RAM that resizes large images and thus needs a lot of memory. The first script increased memory usage to almost 100%, leaving virtually nothing for the SQL Server that was also running (which gave up memory until running on 20 MB instead the usual 900 MB). In the second script we added a GC.Collect() and (to be sure) a one sec thread sleep after each cycle, and everything went back to normal. Question: isn't

System.OutOfMemoryException because of Large Dictionary

半世苍凉 提交于 2019-12-30 09:57:32
问题 I keep a large cache in a dictionary with value IEnumerable<KeyValuePair<DateTime, Double>> . I remove items from the dictionary periodically and add items to the dictionary periodically. Every now and again I get a System.OutOfMemoryException. I wanted to know why doesn't the garbage collector come to my rescue? 回答1: Remember that a Heap can get fragmented as @Gabe mentioned. Even though you might have free memory it might not have a chunk large enough to allocate the dictionary to when it

System.OutOfMemoryException because of Large Dictionary

南笙酒味 提交于 2019-12-30 09:57:22
问题 I keep a large cache in a dictionary with value IEnumerable<KeyValuePair<DateTime, Double>> . I remove items from the dictionary periodically and add items to the dictionary periodically. Every now and again I get a System.OutOfMemoryException. I wanted to know why doesn't the garbage collector come to my rescue? 回答1: Remember that a Heap can get fragmented as @Gabe mentioned. Even though you might have free memory it might not have a chunk large enough to allocate the dictionary to when it