memory-management

Should I release a IBOultet in my dealloc function?

If I have something like this in my .h file: @property (nonatomic,retain) IBOutlet UIButton *btnHelp; Should I release it in the dealloc function of the .m file? ...

How to find memory used by an object in PHP? (sizeof)

How to find memory used by an object in PHP? (c's sizeof). The object I want to find out about is a dictionary with strings and ints in it so it makes it hard to calculate it manually. Also string in php can be of varied length depending on encoding (utf8 etc) correct? ...

Can I tell Mysql which indices to keep in memory regardless of other indices?

My database is bigger than the amount of memory I have on the computer. I would like to keep a couple of most used indices in the memory regardless of all other caching. Do you know if it is possible, and if yes, how it can be done? ...

Why do I get different results when I dereference a pointer after freeing it?

I've a question about the memory management in C (and GCC 4.3.3 under Debian GNU/Linux). According to the C Programming Language Book by K&R, (chap. 7.8.5), when I free a pointer and then dereference it, is an error. But I've some doubts since I've noted that sometimes, as in the source I've pasted below, the compiler (?) seems to work...

android phonegap application fails when loading too much javascript

I have an application that is based on Web 2.0 technologies -- basically I use phonegap / titanium approach to start up a web browser where most of the app is written in javascript and HTML (jQuery, to more precise). The app works great on the emulator, but when I launch it on the G1, it crashes. When I reduce the amount of javascript ...

C++ new int[0] -- will it allocate memory?

A simple test app: cout << new int[0] << endl; outputs: 0x876c0b8 So it looks like it works. What does the standard say about this? Is it always legal to "allocate" empty block of memory? ...

Who is responsible for releasing objects in an array when copying?

In Objective-C, if array1 is copied onto array2 using mutableCopy, and suppose the code is done in main(), who is responsible for releasing the objects contained in the array? Is it main() or array2? ...

UIAlertView fails to show and results in “EXC_BAD_ACCESS” error

A method is called when a return button on the keyboard is pressed. After calling another method which returns an integer a message is created based on that integer. The message is then passed into an UIAlterView and displayed to the user. The alert doesn't have any options (hence why I'm not calling a delegate), but simply notifies the ...

.NET Garbage Collector Basics

I apologize if the answer to this question is trivial. But I still cannot figure out this by myself. How does the garbage collector in .NET identify what objects on the heap are garbage and what objects are not? Lets say a .NET application is running and at a certain point of time garbage collection occurs(lets leave out the generatio...

How does the operating system know how much memory my app is using? (And why doesn't it do garbage collection?)

When my task manager (top, ps, taskmgr.exe, or Finder) says that a process is using XXX KB of memory, what exactly is it counting, and how does it get updated? In terms of memory allocation, does an application written in C++ "appear" different to an operating system from an application that runs as a virtual machine (managed code like ...

HeapCreate vs GetProcessHeap

Hi I'm new to using Heap Allocation in C++. I'm tryin to understand the scenario that will force someone to create a private heap instead of using the Process Heap. Isn't Process Heap generally enough for most of the cases? Thanks --Ashish ...

Flaws in algorithm and algorithm performance

char *stringmult(int n) { char *x = "hello "; for (int i=0; i<n; ++i) { char *y = new char[strlen(x) * 2]; strcpy(y,x); strcat(y,x); delete[] x; x=y; } return x; } I'm trying to figure out what the flaws of this segment is. For one, it deletes x and then tries to copy it's values over to y....

Java memory puzzle

Suppose I have following code package memoryleak; public class MemoryLeak { public static int size; static { size = (int) (Runtime.getRuntime().maxMemory()*0.6); } public static void main(String[] args) throws InterruptedException { { byte[] data1 = new byte[size]; } byte[...

is it necessary to release a NSInteger in iphone?

i am getting this error does some one knows about it??? 2009-07-08 18:42:36.778 FlashCards[1297:20b] Category Id=1 FlashCards(1297,0xa0690fa0) malloc: * error for object 0x4fd78a0: pointer being freed was not allocated FlashCards(1297,0xa0690fa0) malloc: * error for object 0x4fdc200: double free *** set a breakpoint in malloc_error_break...

Does a NSURLConnection retain its delegate?

Summary of my question: Does NSURLConnection retain its delegate? Detailed question and scenario: I have a custom class, called JsonDownloader that is takes in a URL and returns an NSDictionary of the JSON that the URL returns. On an iPhone app, I do something like this. (the init method kicks off the whole process) (void)viewDidLo...

Why do my OCUnit tests fail with "code 138"?

I'm currently trying to learn objective-c using XCode 3.1. I've been working on a small program and decided to add unit testing to it. I followed the steps on the Apple Developer page - Automated Unit Testing with Xcode 3 and Objective-C. When I added my first test, it worked fine when the tests failed, but when I corrected the tests...

How to reduce the memory consumption?

This is a C# problem. I have a big object in memory at a certain time. I want to serialize it to a file. There are two steps to do it. 1st, I need to change the object to csv string. 2nd, I need to serialize the csv string. I have a utility tool, which can append strings to a MemoryStream. I use this utility tool to convert the big obje...

How to avoid reference count underflow in _NSCFURLProtocolBridge in custom NSURLProtocol in GC environment

The basics are I have a custom NSURLProtocol. In startLoading, [self client] is of type: <_NSCFURLProtocolBridge> {NSURLProtocol, CFURLProtocol} The problem is running this in a garbage-collected environment. Because I'm writing a screensaver, I'm forced to make it garbage-collected. However, the _NSCFURLProtocolBridge protocol see...

How can I pin a byte array in Java?

Is there a way to pin a byte array in java, so it never gets moved/compacted? I am working on an application which is intended to have zero GCs during runtime, and I want to use primitive byte arrays that are pinned to a memory mapped area. Is there any way to do this or hack my way to it? ...

Placing elements into the UITableView footer, when to release them?

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { AViewController * aView = [[AViewController alloc] initWithNibName:@"myNib" bundle:[NSBundle mainBundle]]; return vintagePriceRowView.view; } I know this code needs a release... somewhere. But where? If I set the allocated AviewContro...