memory-management

Learn Obj-C Memory Management

I come from a web development background. I'm good at XHTML, CSS, JavaScript, PHP and MySQL, because I use all of those technologies at my day job. Recently I've been tinkering with Obj-C in Xcode in the evenings and on weekends. I've written code for both the iPhone and Mac OS X, but I can't wrap my head around the practicalities of me...

ASP.NET - Single large web request triggers System.OutOfMemoryException - Still have plenty of available memory

Environment: Windows 2003 Server (32 bit); IIS6, ASP.NET 2.0 (3.5); 4Gb Ram; 1 Worker Process We have a situation where we have a very large System.XmlDocument is being loaded into memory, and then it heads into a complied XSL transform. What is happening is when a web request comes in the server is sitting in an idle state with 2500Mb...

Abstract class memory management in Cocoa

When writing an abstract class, or a class that doesn't get instantiated directly... do you tend to write a dealloc method in the abstract class and release where appropriate, and then allow for children to call [super dealloc] and then worry about only instance variables they add which aren't part of the super class? How do you folks m...

C# Dictionary Memory Management

I have a Dictionary<string,int> that has the potential to contain upwards of 10+ million unique keys. I am trying to reduce the amount of memory that this takes, while still maintaining the functionality of the dictionary. I had the idea of storing a hash of the string as a long instead, this decreases the apps memory usage to an accept...

How do stl containers get deleted?

How does container object like vector in stl get destroyed even though they are created in heap? EDIT If the container holds pointers then how to destroy those pointer objects ...

How can a program have a high virtual byte count while the private bytes are relatively low on Windows 32-bit?

I'm trying to get a better understanding of how Windows, 32-bit, calculates the virtual bytes for a program. I am under the impression that Virtual Bytes (VB) are the measure of how much of the user address space is being used, while the Private Bytes (PB) are the measure of actual committed and reserved memory on the system. In particu...

C++ - gsoap : Parameter passing memory management issues

I am writing a web server and client test stub for it. I have questions regarding memory management of the parameters. From my client I am calling a soap function ns1_func1(input * pInput, output* pOutput) Now both input and output class contain pointers to other structs. For e.g class Output { class abc * p1; class def * p2;...

How to reduce the memory usage of a WPF app.

I am working on a little bookmark managing app written in C#, using WPF. It just sits in the system tray and is idle 99% of the time. Recently I looked in the task manager and discovered that it uses around 25 megs of memory (and around 12 megs before it is activated for the first time) which I thought was a bit much for an app that does...

Does the Unix kill command insure that dynamically allocated memory will return properly?

So, I found a bunch of scripts in the project I have been newly assigned to that are the "shutdown" scripts. They just do some basic searches and run the unix "kill" command. Is there any reason they shouldn't shut down the process this way? Does this insure that dynamically allocated memory will return properly? Are there any other ...

GC in multithreaded environment

How to do garbage collection in a program that consist from multiple threads or processes? I also like to know how can I scan the stack from each of those threads and processes? Does each process require it's own garbage collection routine? Is it a good idea to run the garbage collector in a separate thread/process from the actual prog...

.NET Strings vs. Streams - Memory Profile and Characteristics

I need to pull large Unicode textual strings (e.g. 200Mb) from a Database (nvarchar) and store in memory for processing. i.e. I need random access to all parts of the strings. Looking at this from strictly memory centric point of view, what are the pro’s and con’s of using a System.IO.MemoryStream versus a System.String as my in memory ...

What is the best way to do nested TRY AND FINALLY statement in Delphi

Hi What is the best way to do nested try & finally statements in delphi? var cds1 : TClientDataSet; cds2 : TClientDataSet; cds3 : TClientDataSet; cds4 : TClientDataSet; begin cds1 := TClientDataSet.Create(application ); try cds2 := TClientDataSet.Create(application ); try cds3 := TClientD...

Circular References Cause Memory Leak?

I'm trying to run down a memory leak in a windows forms application. I'm looking now at a form which contains several embedded forms. What worries me is that the child forms, in their constructor, take a reference to the parent form, and keep it in a private member field. So it seems to me that come garbage-collection time: Parent ha...

Memory Efficient Programming

What are some best practice for "Memory Efficient C programming". Mostly for embedded/mobile device what should be the guidelines for having low memory consumptions ? I guess there should be separate guideline for a) code memory b) data memory ...

How to sort a string of characters in objective-C?

I'm looking for an Objective-C way of sorting characters in a string, as per the answer to this question. Ideally a function that takes an NSString and returns the sorted equivalent. Additionally I'd like to run length encode sequences of 3 or more repeats. So, for example "mississippi" first becomes "iiiimppssss", and then could be s...

Whats up with static memory in java?

This question is for the java language in particular. I understand that there is a static protion of memory set aside for all static code. My question is how is this static memory filled? Is a static object put into static memory at import, or at first reference? Also, do the same garbage collection rules apply to static objects as they...

When might you not want to use garbage collection?

Garbage collection has been around since the early days of LISP, and now - several decades on - most modern programming languages utilize it. Assuming that you're using one of these languages, what reasons would you have to not use garbage collection, and instead manually manage the memory allocations in some way? Have you ever had to...

What is the best way to track memory management while testing my iPhone App?

While developing my app I have come to realize that the majority of my app crashes have arisen from poor memory management. I understand I can print or log retain counts through NSLog (@"retain count is:%d",[myInstance retainCount]); But isn't there a better, less manual method? Possibly a visual representation of your objects and inst...

How do I go about diagnosing memory corruption errors occurring in a COM-DLL after porting it from Delphi 2007 to Delphi 2009?

I have just ported several of our home-made Outlook COM-addins from Delphi 2007 to Delphi 2009 and am now experiencing some really weird errors (before you ask: none of which appear to have any obvious relationship to string-handling), for example modal dialogs that hang Outlook when one tries to invoke them a second time (the first time...

Profiling for analyzing the low level memory accesses of my program

Hello, I have to analyze the memory accesses of several programs. What I am looking for is a profiler that allow me to see which one of my programs is more memory intensive insted of computing intensive. I am very interested in the number of accesses to the L1 data cache, L2, and the main memory. It needs to be for Linux and if it is po...