memory-management

I am getting the leak in the follwing code ? memory management

Hai Guys, I am getting the leaks as 100%. I don't know how to release the object after it returns Could you explain the procedure how to release the allocated Titles object. -(Titles *)listTiles { Tiles* tile = [[Tiles alloc] init]; tile.googleTile_X = (int)tileX; tile.googleTile_Y = (int) pow(2, aZoom) - 1- tileY ; tile.zoomLevel ...

Where does the stack memory allocated to a thread come from?

I have few questions regarding java GC and memory management. In java we define process memory upper bound and lower bound by xmx and xms parameters. Using these parameters JVM allocates young old and perm space. So if new threads are created then from which memory do stacks memory is allocated to threads? is it from perm space or any ...

Will this Objective-C, nested NSArray cause a memory leak on iPhone?

NSArray *tLines = [[NSArray alloc] initWithObjects: [[NSArray alloc] initWithObjects:@"Matt", @"David", nil], [[NSArray alloc] initWithObjects:@"Bob", @"Ken", nil], nil]; self.lines = tLines; [tLines release]; I'm allocing NSArrays within an NSArray, will the nested arrays get released when I call ...

is permanent generation part of memory reserved using xmx parameter?

In java we can define max memory that process can take using xmx parameter. For perm gen we can define the MaxPermSize. So is the perm gen space is also part of memory allocated using xmx parameter. so is xmx = young + old OR young + old + perm OR young + old + perm + Stack space ? ...

are the new objets assigned from eden space or eden + fromSurvivor space ?

are the new objets assigned from eden space or eden + fromSurvivor space ? can free space in from survivor space be also used for allocation to new objects ? EDIT : consider the scenerio : suppose Eden space is full and from survivor space occupancy is less, then in that case if new object is created (new object is small enough to fit...

How to limit the amount of memory accessible to my C code?

Just to test, I ran this code #include<unistd.h> #include<stdio.h> #include<stdlib.h> int main() { int **ar = (int**) malloc(100000000* sizeof(int*)); int i; for(i = 0; i<10000000; i++) { ar[i] = (int*) malloc(1000 * 4); ar[i][123] = 456; } usleep(3000000); usleep(3000000); usleep(3000000); us...

Iphone: Is this a bad Idea? Memory Management/Leak Issue

I have a class, that basically manages core data. inserts deletes and updates data. I initialize this class like so - (id)init { self = [super init]; if (self) { self.itemList = [NSDictionary dictionaryWithObjectsAndKeys: // <== LEAKS ITEMURL1, KEY1, ITEMURL2, KEY2, ...

where does a "static final" directly allocated into? young gen or old gen or perm gen?

Is a "static final" directly allocated into young gen or old gen or perm gen? (I guess it will most likely land into old gen over the time I suppose.) If it is allocated in the perm gen then, will it be garbage collected when class unloading takes place in Perm Gen ? ...

How does OS locate contents on disk that have not been loaded into memory when page fault exception is raised?

When a page fault exception is raised because the content CPU is trying to access have not been loaded in to memory, how does the OS locate the missing content on the secondary storage (e.g. hard disk)? Thanks for your explanation in advance. -ivan ...

compression, defragmentation, reclaiming space, shrinkdatabase vs. shrinkfile

[1] states: "When data is deleted from a heap, the data on the page is not compressed (reclaimed). And should all of the rows of a heap page are deleted, often the entire page cannot be reclaimed" "The ALTER INDEX rebuild and reorganize options cannot be used to defragment and reclaim space in a heap (but they can used to defragmen...

About the internal logic of "Memory Cannot be read" error in windows

We occasionally come into this error when running a EXE on windows. How does OS know if a specific memory can be read or not? ...

Strange behavior of memcpy/memmove

Hi everybody, I have the problem that memcpy/memmove change the pointer of a struct FOO foo, which is neither src nor destination of the function. Here are the gdb outputs: Before memmove(y,y_temp,size_y);: (gdb) p y $38 = 0xbff7a2e0 (gdb) p y_temp $39 = (float *) 0x815ea20 (gdb) p foo $40 = (FOO *) 0x81d4e90 and after: (gdb) p y_t...

What if a finalizer makes an object reachable?

In Java, finalize is called on an object (that overrides it) when it's about to be garbage collectioned, so when it's unreachable. But what if the finalizer makes the object reachable again, what happens then? ...

Using Instruments to improve memory-management with modal view controllers

I feel like I don't understand something fundamental here. I've been working on memory management in my app while using Instruments to check out live allocations. I have a modal view controller (settingsViewController) that has an image for a background. One thing I noticed was that even after settingsViewController dealloc is called,...

How many bytes does memory arbiter protect?

How many bytes does memory arbiter protect? While reading "Understanding the linux kernel, 3rd edition" chapter 2, section2.1, I encounter the following statement: In multiprocessor systems, all CPUs usually share the same memory; this means that RAM chips may be accessed concurrently by independent CPUs. Because read or write operation...

PHP extension for Linux: reality check needed!

Okay, I've written my first functional PHP extension. It worked but it was a proof-of-concept only. Now I'm writing another one which actually does what the boss wants. What I'd like to know, from all you PHP-heads out there, is whether this code makes sense. Have I got a good grasp of things like emalloc and the like, or is there stuff...

objc_msgSend() error message, why?

Hi. I got the "objc_msgSend()" killer error message in my app and thanks to Hamster Emporium i can figure out a little bit what was happening. Now i found the "problem" and the "solution", but what i can't understand why my problem was really a problem. Here is the scenario: Object_A --> Object_B --> Object_C The '-->' symbol re...

Methods That Call Methods: Basics of Autorelease?

Just when I thought I've understood this topic completely, I'm back to basics. I have a method that instantiates an autoreleased object, using (for example) stringWithFormat: return [NSString stringWithFormat:@"what"]; Then I call this method from another method, and another method, each time returning this autoreleased NSString and ...

Garbage collection of pagecontext attributes java

Consider, pageContext.setAttribute("name", new String("Shal")); String name1= new String("Jason"); pageContext.setAttribute("Alternate Name", name1)); how the memory is allocated for the above two attributes,how and when that memory allocated will be recovered. What is the best practice to follow ...

Why is "operator delete" invoked when I call "delete" on a null pointer?

While reading answers to this question I noticed that answers (this for example) imply that operator delete can be called even when delete statement is executed on a null pointer. So I wrote a small snippet: class Test { public: void* operator new( size_t ) { /*doesn't matter*/ return 0; } void operator delete( void* ptr ) { ...