memory-management

MemoryFailPoint fires to early in WinXP 64

Hello, I have created a volume class (called VoxelVolume) with a self-organizing memory management, since the GC in C# didn't provide a good mechanism for managing contents of the volume for mapping, unmapping and remapping. Although I could have used the mechanisms of virtual memory, the problem is that the files are often too large to...

Basic question on retain/release semantics from Apple's reference library

I have done Objective-C way back when, and have recently (i.e. just now) read the documentation on Apple's site regarding the use of retain and release. However, there is a bit of code in their Creating an iPhone Application page that has me a bit confused: - (void)setUpPlacardView { // Create the placard view -- it calculates its ...

What is the difference between these two different lines of Objective-C, and why does one work and not the other?

If I try and release tempSeedsArray after seedsArray = tempSeedsArray , I get an EXEC_BAD_ACCESS, and Instruments shows that tempSeedsArray has been released twice. Here is my viewWillAppear method: - (void)viewWillAppear:(BOOL)animated { NSString *arrayFilePath = [[NSBundle mainBundle] pathForResource:@"SeedsArray" ofType:@"pli...

Memory management in ipad/iphone app

I have an app where it seems to me that memory is not being release but I am not sure how to analyze this problem. 'Analyze' in xcode shows no problems and 'Instruments' does not show any memory leaks. As far as I have seen, it is not recommended to look at the retain counts. How can I find the problematic objects? I have added printo...

why pointer to pointer is needed to allocate memory in function

Hi I have a segmentation fault in the code below, but after I changed it to pointer to pointer, it is fine. Could anybody give me any reason? void memory(int * p, int size) { try { p = (int *) malloc(size*sizeof(int)); } catch( exception& e) { cout<<e.what()<<endl; } } it does not work in the main funct...

Is there a safe / standard way to manage unstructured memory in C++?

I'm building a toy VM that requires a block of memory for storing and accessing data elements of different types and of different sizes. I've done this by writing a wrapper class around a uint8_t* data block of the needed size. That class has some template methods to write / read typed data elements to / from arbitrary locations in the...

High memory usage for dummies

I've just restarted my firefox web browser again because it started stuttering and slowing down. This happens every other day due to (my understanding) of excessive memory usage. I've noticed it takes 40M when it starts and then, by the time I notice slow down, it goes to 1G and my machine has nothing more to offer unless I close other ...

Qt: QStackedWidget solution

I'm building a Qt application that have about 30 different views (QWidgets). My idea is to use a QStackedWidget to make it easy to switch between the different views in the application. I have two different solutions of how to implement this and use as little memory as possible when the user navigates through the application. Solution ...

Debugging HeapReAlloc failure using GetExceptionCode

Hey folks, Been messing about with this all day and haven't got anywhere so I'm hoping someone can help me - I have a HeapReAlloc method failing with the error ACCESS_VIOLATION, but I'm unsure how to implement a further check using GetExceptionCode as it uses try/catch or exception or something - can someone give me a quick example of h...

When to go for object pooling [c#]?

When to go for object pooling using c#? Any good ex... What are the pro's and con's of maintaining a pool of frequently used objects and grab one from the pool instead of creating a new one? ...

Is there memory usage profiler available?

For time profiler for XYZ, I can just run 'time XYZ', or if I have the source code in C/C++, I even can use gprof to get profiled results. Is there any similar tool for memory usage? Is there any tool I can use something like 'memory XYZ', to get info such as min/max/median memory usage? What tool do you use for memory profile with C+...

Why doesn't free(p) set p to NULL?

Any reasons why this can not be standard behavior of free()? multiple pointers pointing to the same object: #include <stdlib.h> #include <stdio.h> void safefree(void* p = NULL; } int main() { int *p = (int *)malloc(sizeof(int)); *p=1234; int* printf("p=%p p2=%p\n", p, p2); safefree((void* printf("p=%p p2=%p\n"...

Solving iPhone/iPad out of memory issues

I have a strange issue where I'm scrolling through a paged UIScrollView which displays the pages of a PDF document (using Quartz 2D and CATiledLayer). When I page through memory allocation looks fine with it going up with a few initial pages and then keeping it steady as it obviously releases the memory kept for earlier pages. Upon hitti...

Proper way to reassign pointers in c++

EDIT: I know in this case, if it were an actual class i would be better off not putting the string on the heap. However, this is just a sample code to make sure i understand the theory. The actual code is going to be a red black tree, with all the nodes stored on the heap. I want to make sure i have these basic ideas correct before mov...

Released object crashes app

I am using objective-C++ (+Boost) for iPhone development. I am in a rather tight loop and need to allocate and release a certain object. The code is something like this. for (int i=0;i<100;i++) { opt = [[FObj alloc] init]; //do stuff with opt [opt release]; } The FObj object is something like @interface FObj MyCPPObj ...

Memory usage does not drop -- no leaks though

I have UINavigationController controlling several views. One of the views is composed of 20 scrollable pages. Each page is a constructed on the fly from UIViews by adding buttons, labels, UIImageViews etc. When this UIView is popped off the stack, the memory usage remains the same. Hence it keeps rising if I keep pushing/popping that vie...

Help with malloc and free: Glibc detected: free(): invalid pointer

I need help with debugging this piece of code. I know the problem is in malloc and free but can't find exactly where, why and how to fix it. Please don't answer: "Use gdb" and that's it. I would use gdb to debug it, but I still don't know much about it and am still learning it, and would like to have, in the meanwhile, another solution. ...

C++: Unitialized variables garbage

int myInt; cout << myInt; // Garbage like 429948, etc If I output and/or work with unitialized variables in C++, what are their assumed values? Actual values in the memory from the "last user"? e.g.: Program A is closed, it had an int with the value 1234 at 0x1234 -> I run my program, myInt gets the address 0x1234, I output it like...

Retain information in cocoa?

Hello, I'm still new to Cocoa and don't know much about memory management. I read up on Apple's documentation but I'm still confused. My question is if I set the value of a variable in a - (void)dowhatever when dowhatever ends, will the contents of the variable be erased? If so is there a method (without writing to a file) that I can us...

how do addressing modes work on a physical level?

I'm trying to learn this basic thing about processors that should be taught in every CS department of every university. Yet i can't find it on the net (Google doesn't help) and i can't find it in my class materials either. Do you know any good resource on how addressing modes work on a physical level? I'm particularly interested in Inte...