I'm 99% certain the answer to this is a blinding no. Please validate my proposition that the following code will produce a memory leak.
Data &getData()
{
Data *i = new Data();
return *i;
}
void exampleFunc()
{
Data d1 = getData();
Data d2;
/* d1 is not deallocated because it is on the heap, and d2 is
* because...
I am running my c++ application on an intel Xscale device. The problem is, when I run my application offtarget (Ubuntu) with Valgrind, it does not show any memory leaks.
But when I run it on the target system, it starts with 50K free memory, and reduces to 2K overnight. How to catch this kind of leakage, which is not being shown by Valg...
I have an application that allows a user to view details on a specific case w/out a postback. Each time a user requests data from the server I pull down the following markup.
<form name="frmAJAX" method="post" action="Default.aspx?id=123456" id="frmAJAX">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" />
</div>
<div>
<i...
What is the Windows Task Manager "Handles" column a measure of? File Handles? Or Page File Pointers? Also is it bad for one program to have 8000 handles?
Thanks!
...
Greetings,
I'm able to walk a processes memory map using logic like this:
MEMORY_BASIC_INFORMATION mbi;
void *lpAddress=(void*)0;
while (VirtualQuery(lpAddress,&mbi,sizeof(mbi))) {
fprintf(fptr,"Mem base:%-10x start:%-10x Size:%-10x Type:%-10x State:%-10x\n",
mbi.AllocationBase,
mbi.BaseAddress,
mbi.RegionSize...
I've been staring at this same issue for a long time now, and would really appreciate any help or suggestions. I'm sure its something simple, but I can't seem to find it. In my app delegate I'm loading up a bunch of accessory objects (an object I created, which supports NSCopying) with the following code:
NSString *path = [[NSBundl...
Any suggestions for my stack based allocator?
(Except for suggestions to use a class with private/public members)
struct Heap
{
void* heap_start;
void* heap_end;
size_t max_end;
Heap(size_t size)
{
heap_start = malloc(size);
heap_end = heap_start;
max_end = size + (size_t) heap_start;
}
...
In a lay-man terminology how to define garbage collection mechanism. How an object is identified to be available for garbage collection?
In lay-man terms define GC algorithms i.e. Reference Counting, Mark and Sweep, Copying, Train etc?
...
I'm developing an iPhone application and am new to Objective-C as well as SQLite. That being said, I have been struggling w/ designing a practical data management solution that is worthy of existing. Any help would be greatly appreciated.
Here's the deal:
The majority of the data my application interacts with is stored in five tables ...
I want to figure out in which cases I need to care about memory management when it comes to properties. I wrote down something from a site I don't remember anymore, where they said that if a property has any value other than NSNumber or NSValue, and if it has no setter, then UIKit would autorelease the old value and retain the new one. A...
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:
(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[self.pickerTrigger setImage:image];
[self.button setTitle:@" " forState:UIControlStateNormal];
[self.button setTitle:@" " forState:...
As I understand it, I do have to release the top level objects (including window, custom controller objects, ...) from my Nib file, if I load it programmatically by myself.
But do I have to care about them in an simple view-based application that has only one main nib file?
And would I have to care about them when having an view-based ...
Apple says, that I need to have Outlets in my File's Owner for all my top level objects in a Nib file.
As much as I know, these objects are NOT the File's Owner itself (would make no sense, right?) and the First Responder.
I am unsure about: The View object in the Nib, and any controller object in the nib. Do I need an outlet for thos...
Somewhere I was reading that I would run into memory problems when I give up a view temporary due to an low memory warning (loading it again as soon as the user wants to see it), if theViewController class does not do things like this on every outlet of that view:
-(void)dealloc {
[myView release], myView = nil;
[myLabel release...
Currently I am jumping into the ice cold water called "memory management in iPhone OS".
Here's one rule i've learned:
Every time I see an alloc in my method, I will release that corresponding variable at the bottom of the method.
Every time I create an @property(...) in my header file which says copy or retain, I put a release message...
If my application is out of memory when i call new() i will get exception and malloc() i will get 0 pointer.
But what if i call a method with some local variables? They occupy memory too. Is there some way to reserve memory for "normal" variables? So that even though new() throws exception i can just catch it, fix stuff and still call m...
In the NSObject Class Reference they talk about an "isa instance variable" which
is initialized to a data structure that describes the class
can someone explain what I should know about this isa instance variable? What is that good for? What does isa mean? Sounds like a norm, like DIN, ISO, etc.; Any idea what that is?
...
And how would it pertain to performance and memory issues? Is it more a problem on AIX than Solaris or Windows?
...
Here's an sample code, where only the "string" object is released.
NSString *nameOfFile = ... ;
NSError *error;
NSString *string = [[NSString alloc] initWithContentsOfFile:nameOfFile encoding:NSUTF8StringEncoding error:&error];
if (string == nil) {
// handle error
}
[string release];
I understand why the error object is not releas...
I feel that both are the same thing, but I am not sure.
...