memory-management

A shot in the dark - Application bug

Ok so this is gonna be a bit of a shot in the dark without you being able to see my application! I have a bug. I have a SwimmingPool class, my app passes the pool from a tableview into a detail view where you can see all the swimmingPool class fields. You can then click on the individual detail, edit it, and then save it. The 'original'...

why do we need zone_highmem on x86?

In linux kernel, mem_map is the array which holds all "struct page" descriptors. Those pages includes the 128MiB memory in lowmem for dynamically mapping highmem. Since the lowmem size is 1GiB, so the mem_map array has only 1GiB/4KiB=256KiB entries. If each entry size is 32 byte, then the mem_map memory size = 8MiB. But if we could use...

How to check that the memory has been freed in visual studio C++?

Hello, I want to check that all my memory was freed ok in Visual Studio 2008 in C++. I heard that I can add few includes and maybe write some code line and that should do it. Does anyone know how I can do it? Thanks in advance, Greg ...

allocation: struct inherits from the class

If struct inherits from the class, in other words, value type inherits from a reference type, where is memory allocated: heap or stack? Thanks Edit#1 If there is no inheritance allowed, then why is the following legal: class Samplewhere T:class where U:struct, T In the case above, parameter U is value type, and it derives from T...

Fighting fragmentation in custom memory manager

Hi, I've written a c/c++ memory manager for heap allocations (overloaded new/delete and malloc/realloc/free, based on Doug Lea's malloc but designed to be wait free) and seem to be having some trouble with fragmentation. Are there any good resources out there that detail good strategies for avoiding fragmentation via the manager? Pleas...

Toll-free bridging and memory management

My iPhone app needs to do some URL escape sequence encoding for a form parameter. The NSString stringByAddingPercentEscapesUsingEncoding as stringByAddingPercentEscapesUsingEncoding doesn't escape a lot. This is what I have -(NSString*)currentMessageUrlEncoded{ CFStringRef originalURLString = (CFStringRef) self.currentMessage; CFSt...

How is the memory allocation done for variables in scripting languages?

For example, in javascript I can say var x = 5; Later I can do x = 'a'; and then x = "hello"; So, how is memory allocated for the variables? As it is, all variables have a common type 'var' and values of variables can change at run-time as seen above. Isn't it a difficult task to allocate and manage memory for these variables?...

iPhone: helpfulness of didReceiveMemoryWarning:

I'm at the part of my development process for tracking down crashing and memory leaks. As a strategy, do you put any NSLog messages or notifications of some such into didReceiveMemoryWarning: ? The documentation for this method is rather sparse. Is it accurate to say that before a crash will happen, the UIViewController will trigger that...

What kind of odd behavior can occur during a memory leak on the iPhone?

Hi all, I've been able to replicate a bug consistently on an iPhone app I'm working on. The bug always follows as soon as my UIViewController's didReceiveMemoryWarning method gets invoked. Some of the issues I'm seeing are as follows: UITextField's text property niling out. The previous data in the UITextField is getting appended to...

Exception when destroying TReader

The following code throws an EZDecompressionError with message 'Invalid ZStream operation' whenever the line Reader.Free is executed. Can someone tell me what's wrong with this code? Reader := nil; Decompressor := nil; InputFile := TFileStream (FileName, fmOpenRead); try Decompressor := TDecompressionStream.Create (InputFile); Re...

C# memory address and variable

in C#, is there a way to Get the memory address stored in a reference type variable? Get the memory address of a variable? EDIT: int i; int* pi = &i; How do you print out the hex value of pi? ...

When is it not a good idea to pass by reference?

This is a memory allocation issue that I've never really understood. void unleashMonkeyFish() { MonkeyFish * monkey_fish = new MonkeyFish(); std::string localname = "Wanda"; monkey_fish->setName(localname); monkey_fish->go(); } In the above code, I've created a MonkeyFish object on the heap, assigned it a ...

Are there any reasons not to use Boost::shared_ptrs?

I've asked a couple questions (here and here) about memory management, and invariably someone suggests that I use boost::shared_ptrs. Given how useful they seem to be, I'm seriously considering switching over my entire application to use boost::shared_ptrs. However, before I jump in with both feet and do this, I wanted to ask -- Has...

In Flex, what's the best way to remove a swf that was authored in Flash CS3?

So, I have an application where I'll be loading any number of swfs into a SWFLoader and removing them at runtime. The issue is - they are all timeline based movies authored in Flash CS3. I have very little control over what is in the movie other than the authors are not able to program any interactivity (i.e. no event listeners) but I w...

Objective-C memory issue (iPhone)

I'm somewhat confused by the following behavior I'm seeing within an Xcode project compiled for the iPhone simulator (or device): NSString *test = [[NSString alloc] initWithCString:"foo"]; NSLog(@"test retain count = %d", [test retainCount]); // prints 1 [test release]; NSLog(@"test retain count = %d", [test retainCount]); // also pr...

Have you ever used NSZoneMalloc() instead of malloc()?

Cocoa provides for page-aligned memory areas that it calls Memory Zones, and provides a few memory management functions that take a zone as an argument. Let's assume you need to allocate a block of memory (not for an object, but for arbitrary data). If you call malloc(size), the buffer will always be allocated in the default zone. Howev...

Why am I getting an Out Of Memory Exception in my C# application?

My memory is 4G physical, but why I got out of memory exception even if I create just 1.5G memory object. Any ideas why? (I saw at the same time, in the performance tab of task manager the memory is not full occupied, and I could also type here -- so memory is not actually low, so I think I hit some other memory limitations)? using Syst...

Ways to make your program use less memory

Software will use memory, no big suprise, but how do you keep this usage to a minimum in comparison to how big your program is. Best example I think would be Firefox. Some users have experienced it, others haven't, but it's pretty safe to say that all the previous versions of Firefox used much more memory then the current version. Yet s...

Proper stack and heap usage in C++?

I've been programming for a while but It's been mostly Java and C#. I've never actually had to manage memory on my own. I recently began programming in C++ and I'm a little confused as to when I should store things on the stack and when to store them on the heap. My understanding is that variables which are accessed very frequently shou...

Java and virtual memory handling

Is it possible tell the JVM to hint the OS that a certain object should preferably not get pushed out to swap space? ...