memory-management

C++, Seg Faults, and Memory Management

I'm moving from Java to C++ and have really enjoyed it. One thing I don't enjoy is not understanding memory at all because Java used to do that for me. I've purchased a book : Memory as a Programming Concept in C and C++ - Frantisek Franek Are there some good sites for me to go and learn interactively about C/C++ and memory use (tuto...

Memory Management Basics - Objective C

I have a general question about objects, memory, and retaining. I am not a complete newb (I have apps for sale on the iTunes Store) but something must have slipped past me. I work with the Google Docs API, and yesterday I was downloading a spreadsheet feed, and enumerating the results, namely, the Spreadsheet Record Feed. After enumer...

VirtualAlloc alignment

Will the memory block returned by VirtualAlloc always be aligned with the page size? In other words, will the modulus always be zero of the return value from VirtualAlloc and the page size? ...

What is the correct way to Manage memory in an iPhone app for an instance variable that is frequently reassigned to newly allocated memory?

I'm having trouble figuring out how to manage memory for an instance variable that needs to maintain it's current state for a period of time, then be reassigned to newly allocated memory. Take the following example for the instance variable "importantData".: -(void)Update { importantData = [[self getObject] retain]; } - (SomeObjec...

What causes page fault and how to minimize them?

When examining a process in Process Explorer, what does it mean when there are several page faults? The application is processing quite a bit of data and the UI is not very responsive. Are there optimizations to the code that could reduce or eliminate page faults? Would increasing the physical RAM of the system make a difference? ...

Significance of PermGen Space

What is the significance of PermGen space in java? ...

Is it safe to pass (synchronously) stack-allocated memory to other thread?

Recently I heard that memory in the stack is not shared with other thread and memory in the heap is shared with other threads. I normally do: HWND otherThreadHwnd; DWORD commandId; // initialize commandId and otherThreadHwnd struct MyData { int data1_; long data2_; void* chunk_; }; int abc() { MyData myData; // initialize ...

How do you manage releasing an object created in an instance method on iPhone without autorelease?

I'm fairly new to iPhone development and I've hit a roadblock in my understanding of memory management. I've read through the Memory Management Guide for Cocoa and have read many, many questions and answers on SO, but have not found a complete answer. If I have an instance method that creates an object, every example I've seen seems to ...

Qt, Python and Memory Management

Hello , Thanking everybody before starting. I have a serious issue with a GUI implemented in Qt,say,QGui. Through Python APIs,say,qpread etc. I accesses the hardware resources. What i does is through Python script I calls these APIs according to my requirement. This QGui mostly crashes while running the script whether it is for long...

querying for memory details in shell

Hi, Is there a shell command to know about how much memory is being used at a particular moment and details of how much each process is using, how much virtual memory is left etc? ...

using and web service call

What does the using statement do? Is it actually needed? using (MyWebservice x = new MyWebservice()) { //random code } ...

Setting text for NSTextView with an NSString variable, considering reference counting

I have the following code in a function in my .m file: desc = [my executeFunction]; // desc is returned by executeFunction data = [desc objectAtIndex:0]; // data is declared in the .h file data2 = [desc objectAtIndex:1]; [myTextField setString:data]; // myTextField is connected to an NSTextView in IB [myTextField setString:da...

How to determine the total character length of the elements of an array of char pointers?

I got the following problem: I have an array of char pointers char *opts[] = { "-a", "--append", "-b" }; and a command name stored in char cmd[] = "ls"; Now I need to compute all possible combinations, which I've done using the GNU Scientific Library and execute the command with the compute combinations. The problem I have is ho...

When NSThread returns to a released object? (iPhone)

Hi I have got a memory bug that seems to boil down to something happening in a thread. I am having difficulties troubleshooting this. I have a UIViewController, that when active, i.e. the user is using its view, retrieves updates from a web service in an NSThread. This is done every 3 minutes and this delay is controlled by a: [self ...

iPhone: Is this a leak or not

Recently someone on Stack Overflow told me that the code below does not leak, that the property handles retention itself: self.locationManager = [[CLLocationManager alloc] init]; in dealloc : self.locationManager = nil; where in the .h file: @property (nonatomic, retain) CLLocationManager *locationManager; I thought that was ...

Proper vector memory managment

I'm making a game and I have a vector of bullets flying around. When the bullet is finished, I do bullets.erase(bullets.begin() + i); Then the bullet disappears. However it does notseem to get rod of the memory. If I create 5000 bullets then create 5,000 more after those die off, memory stays the same, but if I create 5,000 more while th...

When does setting an Objective-C property double retain?

Given the following code @interface MyClass { SomeObject* o; } @property (nonatomic, retain) SomeObject* o; @implementation MyClass @synthesize o; - (id)initWithSomeObject:(SomeObject*)s { if (self = [super init]) { o = [s retain]; // WHAT DOES THIS DO? Double retain?? } return self } @end ...

calloc -- Usefulness of zeroing out memory

Hi, What is the advantage of zeroing out memory (i.e. calloc over malloc)? Won't you change the value to something else anyways? -Chris ...

How MMU detects double free of a pointer?

How the memory management unit(MMU) detects the double free of a pointer? I know that its a good practice to make the pointer NULL just after freeing it, but suppose programmer does not do it. Is there any MMU mechanism to detect it? ...

How can you force a memory limit in Django WSGI apps?

I want my app to throw an MemoryError when its usage goes over 1GB. I'm running in WSGI daemon mode. I see 3 places the memory limit could be: apache.conf wsgi somewhere django configuration but I can't find the right config options. In PHP you can do this with : php_value memory_limit 1GB in your apache.conf ...