I have some code in my application that looks something like this:
char *hash = (char*) sqlite3_column_text(get_bookmark, 0);
NSString* postHash = [NSString stringWithUTF8String:hash];
This works for me every time; I've never seen it not work. Most of my users do not experience problems (as far as I know). However I find that postHash...
Similar to the known memory leak issue regarding creating and destroying an instance of the UIImagePickerController, I'm finding similar problems regarding instances of the UIViewController class. The recommended way to use the UIImagePickerController is to create the instance once and keep it around for the lifetime of the application,...
Compare these two largely identical functions. In the first, the memory for buff is allocated using _alloca. This works fine. In the second, calloc and free are used instead of _alloca. This crashes.
The weird thing is that I use the calloc/free technique in almost every other GMP wrapping function I have and they all work. Here they d...
The first line of code creates a memory leak, even if you do [self.editMyObject release] in the class's dealloc method. self.editMyObject is of type MyObject. The second line incurs no memory leak. Is the first line just incorrect or is there a way to free the memory?
//creates memory leak
self.editMyObject = [[MyObject alloc] init...
Application Background
Our platform is a click-once WPF application. We have a "shell" that contains a navigation menu structure and it hosts our own custom "page" classes. When you navigate to a new page, we swap out the content of the shell (essentially).
Problem
So, I work for a company that is working on a extremely large softwar...
In C can a function expose memory that it "manageds" at a lower level as readonly to those calling that function (exposing its address). return * const is not effective but I wondered if I was overlooking a programming tick?
Thanks.
const uint8_t * get_value(int index)
{
static uint8_t data[2] = {0, 0};
return (const uint8_t *)&data[i...
I'm using the NSURLConnection class to download a large file in my iPhone application, but it crashes every so often because it's using too much memory. I'm doing the usual NSURLConnection usage, to append the received data to a NSMutableData object.
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[s...
I need to check how much memory is allocated in the heap. Is there a way to get this value programmatically with C#?
I know about the System.Runtime.InteropServices.Marshal.SizeOf(...) but that only tells me the size of an object.
...
Friends
In our C++ , Iam current using realloc method to resize the memory allocated by malloc.
realloc() usage is done as below
my_Struct *strPtr =(my_struct*)malloc(sizeof(my_Struct));
/* an later */
strPtr = (my_struct*)realloc(strPtr,sizeof(my_Struct)*NBR);
now wikipeadia (_http://en.wikipedia.org/wiki/Malloc)says that
If in...
I am taking over some applications from a previous developer. When I run the applications through Eclipse, I see the memory usage and the heap size increase a lot. Upon further investigation, I see that they were creating an object over-and-over in a loop as well as other things.
I started to go through and do some clean up. But the mor...
The obvious cases for not using garbage collection are hard realtime, severely limited memory, and wanting to do bit twiddling with pointers. Are there any other, less discussed, good reasons why someone would prefer manual memory management instead of GC?
...
What is the size of a heap-allocated Object in .net, including management overhead? I'm assuming Objects are allocated along 4-byte boundaries, or is a different approach used?
...
What is the overhead of generating a lot of temporary objects (i.e. for interim results) that "die young" (never promoted to the next generation during a garbage collection interval)? I'm assuming that the "new" operation is very cheap, as it is really just a pointer increment. However, what are the hidden costs of dealing with this te...
I have a large object I'd like to serialize to disk. I'm finding marshal works quite well and is nice and fast.
Right now I'm creating my large object then calling marshal.dump . I'd like to avoid holding the large object in memory if possible - I'd like to dump it incrementally as I build it. Is that possible?
The object is fairly si...
If my application has too many static variables or methods, then as per definition they will be stored in heap. Please correct me if I am wrong
1) Will these variables be on heap until application is closed?
2) Will they be available for GC at any time? If not can I say it is a memory leak?
...
I'm writing an iPhone app. I have a header file that looks like this:
@interface EditTagsViewController : UITableViewController {
NSMutableArray *allTags;
NSMutableArray *selectedTags;
NSInteger currentFavorite;
}
@property (nonatomic, retain) NSMutableArray *allTags;
@property (nonatomic, retain) NSMutableArray *selectedTags;
@...
The legacy database that I'm interfacing with uses a data buffer to pass rows to applications. To handle this in C#, I wrote a class that provides methods for reading and writing different types in the buffer. Each data file uses one data buffer, but the buffer has to be resized for certain operations. To do this, I added an Allocate met...
I'm allocating a block of memory in C# to retrieve information from an unmanaged data buffer:
handle = Marshal.AllocHGlobal(33455);
The maximum size of the information retrieved is 33,455 bytes, but the size of the information may be smaller than that in some cases.
How can I determine how many bytes are actually being used in the al...
how to check an object have been release from the memory?
i know a object have to be release manually when we use alloc|copy|retain to create that object. if use the instance class method(NSString stringwithformat:), the object will be release automactically by NSAutoRealeasePool,however, sometime there have some object used to release ...
I have a large number objects which are tree like structures. I have a problem that the amount of memory the application uses starts to approach >1GB which means performance on the machine drops off and that there are out of memory instructions.
i managed to solve this by using sqlite to put the objects to tables and thus effectively ma...