memory-management

Why is this leaking memory? UIImage `cellForRowAtIndexPath:`

陌路散爱 提交于 2019-12-23 05:04:02
问题 Instruments' Leaks tells me that this UIImage is leaking: UIImage *image = [[UIImage alloc] initWithContentsOfFile:[imagesPath stringByAppendingPathComponent:[NSString stringWithFormat:@"/%@.png", [postsArrayID objectAtIndex:indexPath.row]]]]; // If image contains anything, set cellImage to image. If image is empty, try one more time or use noImage.png, set in IB if (image != nil){ // If image != nil, set cellImage to that image cell.cellImage.image = image; } image = nil; [image release];

how to differentiate two very long strings in c++?

北城余情 提交于 2019-12-23 05:00:22
问题 I would like to solve Levenshtein_distance this problem where length of string is too huge . Edit2 : As Bobah said that title is miss leading , so i had updated the title of questoin . Initial title was how to declare 100000x100000 2-d integer in c++ ? Content was There is any way to declare int x[100000][100000] in c++. When i declare it globally then compiler produces error: size of array ‘x’ is too large . One method could be using map< pair< int , int > , int > mymap . But allocating and

Why won't the Excel process close while app is running

心已入冬 提交于 2019-12-23 04:52:28
问题 Question: Why won't the Excel process close while app is running? Please don't jump the gun and mark it duplicate. If you could show the change needed in the code I really appreciate it. Excel process closes nicely when I close the app . I researched this problem for last few day read several SO posts and tried several things but nothing is working except for calling process.kill which I prefer to avoid if possible. Imports Microsoft.Office.Interop Imports System.Runtime.InteropServices

How fast is the jscript garbage collector? Three.js Matrix Rotations

主宰稳场 提交于 2019-12-23 04:35:29
问题 I am using these two functions in order to rotate my objects in my three.js scenes // Rotate an object around an arbitrary axis in object space function rotateAroundObjectAxis(object, axis, radians) { rotationMatrix = new THREE.Matrix4(); rotationMatrix.makeRotationAxis(axis.normalize(), radians); object.matrix.multiplySelf(rotationMatrix); // post-multiply object.rotation.getRotationFromMatrix(object.matrix, object.scale); delete rotationMatrix; } // Rotate an object around an arbitrary axis

Load UIImagePickerController faster?

余生长醉 提交于 2019-12-23 04:22:17
问题 I need to load UIImagePickerController faster. My app will call UIImagePickerController from possibly multiple controllers and within each controller there are two buttons, one for Photo Library, another for Camera. This is my sample app. Some solutions I tried are recommended by Apple in ' Concurrency Programming Guide '. The simplest is to alloc & init an instance when user presses a button. This can take up to 2 seconds before the camera shows up. Solution attempt:- (1) I made a @property

Smart caching of expensive objects in Python

故事扮演 提交于 2019-12-23 04:18:12
问题 I have a directory of images in order. Typically my code will be using data from a sequential subset of images (e.g. images 5-10), and the naive options for accessing these are: Create a wrapper object with a method that loads the image when needed and reads my data (e.g. a pixel value). This has little memory overhead but will be slow as it will need to load each image every time. Store all the images in memory. This will be fast but obviously there's a limit to how many images we can store.

Out of memory error in opencv3.0 which is running inside docker container

只愿长相守 提交于 2019-12-23 04:14:20
问题 OpenCV Error: Insufficient memory (Failed to allocate 995522496 bytes) in OutOfMemoryError. base_features, base_descs = detector.detectAndCompute(base_img, None) In this particular line the length("len(base_descs)") of base_desc is around 70000. base_desc is a numpy array . I am currently using 4 GB RAM but still it is showing this error. I am running this code inside a docker container , The above code is working fine when i run the python code without using the container in the system. 回答1:

Application get stuck when drawing nearly 40 Scatter Plots using Core Plot in IPad

与世无争的帅哥 提交于 2019-12-23 03:57:07
问题 I am developing an iPad app , it has the option to show Scatter Plots user able to plot the points.I have used core plot library.i have to show 40 Scatter plots in a view controller. my application becomes not responding and get quits when i load 25 graphs. Is there any limitation (No.of Scatter plot counts) in Core plot for a View Controller to show? What is the optimal way to load Scatter Plots using Core Plot? 回答1: There's no hard limit on the number of graphs, but you will eventually run

Which scenario is lighter/heavier on heap allocations?

妖精的绣舞 提交于 2019-12-23 03:54:26
问题 As a follow-up to a previous answer to another question, I became curious of how heap allocations work in a loop. Take the following two scenarios for example: Declaration: SomeList: TObjectList<TSomething>; Scenario 1: begin for X := 1 to 10 do SomeList[X].DoSomething; end; Scenario 2: var S: TSomething; begin for X:= 1 to 10 do begin S:= SomeList[X]; S.DoSomething; end; end; Now what I'm curious about is how heap allocations work in either scenario. Scenario 1 is directly calling the list

Clear QML image cache

拥有回忆 提交于 2019-12-23 03:52:09
问题 I have a QML Flickable with 3 QML image elements that cycle through 8 image files. My problem is that this uses a lot of memory on a Symbian device with very little. So when someone minimizes the app there isn't a lot of memory left for other apps. I want to know what function I can use on the focus lost event to release the cache. Otherwise Symbian closes my app when the phone runs out of memory. 回答1: I just ran into a very similar situation (literally). Apparently the QML cache is hardcoded