memory-management

Implementing NSCopying in Subclass of Subclass

一笑奈何 提交于 2019-12-30 02:38:05
问题 I have a small class hierarchy that I'm having trouble implementing copyWithZone: for. I've read the NSCopying documentation, and I can't find the correct answer. Take two classes: Shape and Square . Square is defined as: @interface Square : Shape No surprise there. Each class has one property, Shape has a "sides" int, and Square has a "width" int. The copyWithZone: methods are seen below: Shape - (id)copyWithZone:(NSZone *)zone { Shape *s = [[Shape alloc] init]; s.sides = self.sides; return

How MTRR registers implemented? [closed]

蓝咒 提交于 2019-12-30 02:33:10
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . x86/x86-64 exposes MTRR (Memory-type-range-register) that can be useful to designate different portions of physical address space for different usages (e.g., Cacheable, Unchangeable, Writecombining, etc.). My question is is anybody knows how these constrained on physical address space as defined by the MTRRs are

Clear MKMapView's cache of tiles?

こ雲淡風輕ζ 提交于 2019-12-30 02:25:50
问题 I'm working on an iPhone game that uses an MKMapView as the playfield. After only a couple of minutes of play the app inevitably starts to get sluggish and eventually crashes due to low memory. After digging around the culprit seems to be that the map view constantly demands more memory. The game requires a lot of zooming and panning of the map so I can only assume that the map's cache of tiles just keeps growing until it runs out of memory. Is there any way to force the map view to flush it

Clear MKMapView's cache of tiles?

风格不统一 提交于 2019-12-30 02:25:06
问题 I'm working on an iPhone game that uses an MKMapView as the playfield. After only a couple of minutes of play the app inevitably starts to get sluggish and eventually crashes due to low memory. After digging around the culprit seems to be that the map view constantly demands more memory. The game requires a lot of zooming and panning of the map so I can only assume that the map's cache of tiles just keeps growing until it runs out of memory. Is there any way to force the map view to flush it

Memory leak in Three.js

ⅰ亾dé卋堺 提交于 2019-12-30 02:13:53
问题 We are trying to create a single page app in which user can switch between multiple Three.js apps. However we are noticing constant increase in memory usage by the tab. Their is no memory leakage in our app and seems Three.js variables are not getting cleared from RAM. Steps to recreate Visit http://threejs.org/examples/ and open Task manager in Google Chrome to notice memory usage by the concerned tab. Keep switching between examples and you will notice constant increase in memory usage and

Are local variables in static methods also static?

北城余情 提交于 2019-12-30 02:01:07
问题 I am wondering do all the local variables become static if we declare them in a static method ? for example: public static void A(){ int x [] = {3,2}; changeX(x); for (int i = 0; i< x.length; i++){ System.out.println(x[i]); // this will print -1 and 1 } } private static void changeX(int[] x){ x[0] = -1; x[1] = 1; } As far as I understand that Java is pass by value always, but why the state of X has changed after we made the changeX call ? Can anyone explain that please ? and can anyone

If I allocate memory in one thread in C++ can I de-allocate it in another

拥有回忆 提交于 2019-12-30 01:59:10
问题 If I allocate memory in one thread in C++ (either new or malloc) can I de-allocate it in another, or must both occur in the same thread? Ideally, I'd like to avoid this in the first place, but I'm curious to know is it legal, illegal or implementation dependent. Edit: The compilers I'm currently using include VS2003, VS2008 and Embedded C++ 4.0, targetting XP, Vista, Windows 7 and various flavours of Windows CE / PocketPC & Mobile. So basically all Microsoft but across an array of esoteric

What data structure is used to implement the dynamic memory allocation heap?

本小妞迷上赌 提交于 2019-12-29 19:46:10
问题 I always assumed a heap (data structure) is used to implement a heap (dynamic memory allocation), but I've been told I'm wrong. How are heaps (for example, the one implemented by typical malloc routines, or by Windows's HeapCreate , etc.) implemented, typically? What data structures do they use? What I'm not asking: While searching online, I've seen tons of descriptions of how to implement heaps with severe restrictions . To name a few, I've seen lots of descriptions of how to implement:

Memory Warning UIImagepickerController IOS 7

最后都变了- 提交于 2019-12-29 18:51:26
问题 Could anybody help me with this issue I'm a bit new to objective c and iOS. I've been working on it but I can't figure out how to fix the problem, My app is really simple it only start the camera take pictures and send them through email to our server. This code was working just fine in iOS6. When I take pictures my memory is heap growth with each screen capture and I get "Received Memory Warning" and finally - Terminated due to Memory Pressure. - -(void)imagePickerController:

How do I force a program to appear to run out of memory?

只愿长相守 提交于 2019-12-29 16:28:14
问题 I have a C/C++ program that might be hanging when it runs out of memory. We discovered this by running many copies at the same time. I want to debug the program without completely destroying performance on the development machine. Is there a way to limit the memory available so that a new or malloc will return a NULL pointer after, say, 500K of memory has been requested? 回答1: Try turning the question on its head and asking how to limit the amount of memory an OS will allow your process to use