memory-management

Python matplotlib: memory not being released when specifying figure size

邮差的信 提交于 2019-12-31 11:41:22
问题 I'm using matplotlib to generate many plots of the results of a numerical simulation. The plots are used as frames in a video, and so I'm generating many of them by repeatedly calling a function similar to this one: from pylab import * def plot_density(filename,i,t,psi_Na): figure(figsize=(8,6)) imshow(abs(psi_Na)**2,origin = 'lower') savefig(filename + '_%04d.png'%i) clf() The problem is that the memory usage of the python process grows by a couple of megabytes with every call to this

Burst memory usage in Java

旧巷老猫 提交于 2019-12-31 11:41:01
问题 I am trying to get a handle on proper memory usage and garbage collection in Java. I'm not a novice programmer by any means, but it always seems to me that once Java touches some memory, it will never be released for other applications to use. In that case, you have to make sure your peak memory is never too high, or your application will continually use whatever the peak memory usage was. I wrote a small sample program trying to demonstrate this. It basically has 4 buttons... Fill class

How to Remove a Previous ViewController

蓝咒 提交于 2019-12-31 10:40:29
问题 I am a student and pretty new to programming. I am trying to learn Objective-C/Swift in my spare time. I made a game using spriteKit with swift that has multiple menus/scenes. I am trying to transition from one view controller to another. To do this I used this code: @IBAction func PlayButtonPressed(sender: AnyObject) { let playStoryboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil) let vc : UIViewController = playStoryboard.instantiateViewControllerWithIdentifier("playGame") as

c# structs/classes stack/heap control?

元气小坏坏 提交于 2019-12-31 09:04:51
问题 so in c++ it's very easy. you want whatever class/struct to be allocated on the heap, use new. if you want it on the stack, don't use new. in C# we always use the new keyword, and depending on whether it's a struct or a class it's allocated either on the stack or on the heap (structs go to the stack, classes to the heap) - and in some applications there can be a HUGE performance difference when changing the design such that only those objects go to the heap that really belong there. What I

c# structs/classes stack/heap control?

依然范特西╮ 提交于 2019-12-31 09:04:31
问题 so in c++ it's very easy. you want whatever class/struct to be allocated on the heap, use new. if you want it on the stack, don't use new. in C# we always use the new keyword, and depending on whether it's a struct or a class it's allocated either on the stack or on the heap (structs go to the stack, classes to the heap) - and in some applications there can be a HUGE performance difference when changing the design such that only those objects go to the heap that really belong there. What I

Manual retain with ARC

谁说我不能喝 提交于 2019-12-31 08:57:08
问题 Before ARC I had the following code that retains the delegate while an async operation is in progress: - (void)startAsyncWork { [_delegate retain]; // calls executeAsyncWork asynchronously } - (void)executeAsyncWork { // when finished, calls stopAsyncWork } - (void)stopAsyncWork { [_delegate release]; } What is the equivalent to this pattern with ARC? 回答1: Why not just assign your delegate object to a strong ivar for the duration of the asynchronous task? Or have a local variable in

Why is PermGen space growing?

删除回忆录丶 提交于 2019-12-31 08:52:29
问题 I've read a few articles, and I understood the following (please correct me and/or edit the question if I'm wrong): The java heap is segmented like this: Young Generation: objects that are created go here, this part is frequently and inexpensively garbage collected Old Generation: objects that survive the garbage collections of the Young generation go here, this area is garbage collected less frequently and using a more CPU demanding process/algorithm (I believe it's called mark-sweep) Edit:

C#: How to implement a smart cache

别等时光非礼了梦想. 提交于 2019-12-31 08:29:17
问题 I have some places where implementing some sort of cache might be useful. For example in cases of doing resource lookups based on custom strings, finding names of properties using reflection, or to have only one PropertyChangedEventArgs per property name. A simple example of the last one: public static class Cache { private static Dictionary<string, PropertyChangedEventArgs> cache; static Cache() { cache = new Dictionary<string, PropertyChangedEventArgs>(); } public static

Does “self.propery = [[SomeClass alloc] init];” leak memory?

大城市里の小女人 提交于 2019-12-31 06:40:21
问题 Is it safe in Objective-C to write self.propery = [[SomeClass alloc] init]; instead of SomeClass *tmp = [[SomeClass alloc] init]; self.property = tmp; [tmp release]; or will the first form leak memory? 回答1: The first example leaks unless you provide a custom property setter. You can use: self.propery = [[[SomeClass alloc] init] autorelease]; Instead. 回答2: It depends on how the property is defined. If it's defined with retain or copy then, yes, your first example will leak. 回答3: The first one

Video, memory management problems in Internet Explorer and Edge from many videos on page causing them to display dark/black and/or not play

落爺英雄遲暮 提交于 2019-12-31 05:43:08
问题 We have a page that contains 77 or so video thumbnails. When a video thumbnail is hovered over, video starts playing within the thumbnail space. A problem occurs after many (8 to 60 depending on the system/browser) of them get hovered over. The video starts playing incorrectly, or not playing. Basically the flat/redundant areas turn all dark. In Edge, this corrects itself after a second or two, but for our client this is very undesirable behavior. We made an improvement by pausing each video