memory-management

Objective-C Memory Management: crash on release

北城余情 提交于 2019-12-31 05:14:17
问题 I'm new to Objective-C and can't seem to get the memory management code right. I have the following code: Media* myMedia = [self.myMediaManager getNextMedia]; self.navigationItem.title = [self.myMediaManager getCategory]; [self.btnImage setImage:myMedia.imageFile forState: UIControlStateNormal]; [self.lblImage setText:myMedia.imageLabel]; //[myMedia release]; My app crashes if I uncomment the above line. Do I need to do something special when I instantiate myMedia? EDIT: If myMediaManager is

Using NSGlyph and memory allocation

こ雲淡風輕ζ 提交于 2019-12-31 04:49:05
问题 in a method to track line breaks frequently , for a NSTextView visibleRect , i am allocating memory for NSGlyph to use NSLayoutManager getGlyphs:range: . should/can i find out how much memory this should be since i have a reference for the range (without affecting layout), and also, what kind of cleanup should happen -- running with ARC ? the code (which runs on a main queue) : NSLayoutManager *lm = [self.textView layoutManager]; NSTextContainer *tc = [self.textView textContainer]; NSRect

Memory Management with returning char* function

霸气de小男生 提交于 2019-12-31 04:43:28
问题 Today, without much thought, I wrote a simple function return to a char* based on a switch statement of given enum values. This, however, made me wonder how I could release that memory. What I did was something like this: char* func() { char* retval = new char[20]; // Switch blah blah - will always return some value other than NULL since default: return retval; } I apologize if this is a naive question, but what is the best way to release the memory seeing as I cannot delete the memory after

IsolatedStorage causes Memory to run out

筅森魡賤 提交于 2019-12-31 04:36:11
问题 hey. I'm reading an image from Isolated Storage when the user clicks on an item like this: using (IsolatedStorageFile currentIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()) { using (var img = currentIsolatedStorage.OpenFile(fileName, FileMode.Open)) { byte[] buffer = new byte[img.Length]; imgStream = new MemoryStream(buffer); //read the imagestream into the byte array int read; while ((read = img.Read(buffer, 0, buffer.Length)) > 0) { img.Write(buffer, 0, read); } img

Problems with memory management, autorelease, permanent heap is sometimes 250+ kb on iOS

﹥>﹥吖頭↗ 提交于 2019-12-31 04:05:12
问题 I'm really pulling my hair out on this one, it seems that I'm having severe issues with memory management on an iOS app. Here's the case: first I load table. When the user taps a cell, it presents a complicated view. The most memory consuming about the view is that it's loading 20+ UIImage s of 500x500. There are two other tabs in that view, loading a list of media (those UIImage s, but then in a table) and another simple table. When I return back to the first table view, apparently over 250

Python numpy.fft changes strides

随声附和 提交于 2019-12-31 04:01:49
问题 Dear stackoverflow community! Today I found that on a high-end cluster architecture, an elementwise multiplication of 2 cubes with dimensions 1921 x 512 x 512 takes ~ 27 s. This is much too long since I have to perform such computations at least 256 times for an azimuthal averaging of a power spectrum in the current implementation. I found that the slow performance was mainly due to different stride structures (C in one case and FORTRAN in the other). One of the two arrays was a newly

How can I demonstrate a zombie object in Swift?

随声附和 提交于 2019-12-31 03:45:07
问题 I've read How to demonstrate memory leak and zombie objects in Xcode Instruments? but that's for objective-c. The steps don't apply. From reading here I've understood zombies are objects which are: deallocated but something pointer is still trying to point to them and send messages to them. not exactly sure how that's different from accessing a deallocated object. I mean in Swift you can do: var person : Person? = Person(name: "John") person = nil print(person!.name) Is person deallocated?

In XNA, what is the best method to dispose of textures I no longer need?

微笑、不失礼 提交于 2019-12-31 03:23:25
问题 I started a project with the concept of reusing the same texture2d objects continuously throughout the game, reloading new textures periodically. Over time this proved a bad idea as I was running in to: System.OutOfMemoryException bool loadImages(string image) { System.Diagnostics.Debug.WriteLine("beginning loading textures " + image); try { //image_a = null; //image_o = null; //image_o.Dispose(); //image_a.Dispose(); image_o = Content.Load<Texture2D>("images/"+image); image_a = Content.Load

how to increase memory limit in Visual Studio C++

依然范特西╮ 提交于 2019-12-31 03:13:26
问题 Need Help.I'm stuck at a problem when running a C++ code on Windows- Visual Studio. When I run that code in Linux environment, there is no restriction on the memory I am able to allocate dynamically(till the size available in RAM). But on VS Compiler, it does not let me create an array beyond a limited size. I've tried /F option and 20-25 of google links to increase memory size but they dont seem to help much. I am currently able to assign only around 100mb out of 3gb available. If there is a

Handle memory while reading long lines from a file in C

北慕城南 提交于 2019-12-31 02:43:10
问题 First of all, I know this question is very close to this topic, but the question was so poorly worded that I am not even sure it is a duplicate plus no code were shown so I thought it deserved to be asked properly. I am trying to read a file line by line and I need to store a line in particular in a variable . I have managed to do so quite easily using fgets , nevertheless the size of the lines to be read and the number of lines in the file remain unknown . I need a way to properly allocate