memory-management

.NET Garbage Collector - Terminal Services

Is there one Garbage Collector for an entire system one instance of a garbage collector for each user that is logged in one garbage collector for each running .NET application Or is it none of the above (please explain)? ...

String manipulation without memory leaks?

I'd like to do a series of string substitutions to removed xml-escaped chars such as '&'. 1) Is there an existing UIKit function that can do this? 2) If not, what's the best way to do it without leaking memory? Here's the idea: -(NSString*) unescape:(NSString*)string { string = [string stringByReplacingOccurrencesOfString:@"&...

Which data structure uses more memory?

Which type of data structure uses more memory? Hashtable Hashmap ArrayList Could you please give me a brief explanation which one is less prone to memory leakage? ...

Any way to make this relatively simple (nested for memory copy) C++ code more effecient?

I realize this is kind of a goofy question, for lack of a better term. I'm just kind of looking for any outside idea on increasing the efficiency of this code, as it's bogging down the system very badly (it has to perform this function a lot) and I'm running low on ideas. What it's doing it loading two image containers (imgRGB for a fu...

Is there a way to avoid errors when releasing an object while code is still running?

I have a UIView subclass that draws itself when -drawRect: is called. It only takes a moment, but under extreme circumstances, such as low memory and deletion of the instance when going to another view controller, the draw function doesn't complete before the the object is deallocated. How am I supposed to deal with this issue? The de...

How can I increase memory security in Delphi?

Is it possible to "wipe" strings in Delphi? Let me explain: I am writing an application that will include a DLL to authorise users. It will read an encrypted file into an XML DOM, use the information there, and then release the DOM. It is obvious that the unencrypted XML is still sitting in the memory of the DLL, and therefore vulnerab...

Reserve memory for list in Python?

When programming in Python, is it possible to reserve memory for a list that will be populated with a known number of items, so that the list will not be reallocated several times while building it? I've looked through the docs for a Python list type, and have not found anything that seems to do this. However, this type of list buildin...

Memory management. Is this single line of code correct?

Do I have a leak with this statement? //Pass the copy onto the child controller self.childController.theFoodFacilityCopy = [self.theFoodFacility copy]; My property is set to: @property (nonatomic, retain) FoodFacility *theFoodFacilityCopy; The reason I think I have a leak is because copy retains the value and then my dot syntax prop...

NSData - Which is better in terms of memory usage: initWithContentsOfURL or NSURLConnection

Hi I want to get an NSData object's contents from a URL. What is the more efficient way of doing this in terms of memory usage dataWithContentsOfURL (or initWithContentsOfURL) or using NSURLConnection? Should I use NSData *data = [[NSData alloc] initWithContentsOfURL:myURL] or NSData *data = [NSURLConnection sendSynchronousRequest:...

Concatenating two memory buffers without memcpy.

In C I have a function foo(char *) that accepts a memory pointer. in the caller, I have two different memory buffers, which I need to concatenate so I can pass one pointer foo(). Is there a way for me to do that without actually copying one buffer to the end of the other buffer and without changing foo() itself? I.e make the two buffers...

A 90/10 Rule for Memory Management?

Most programmers agree that garbage collection is a great thing, and in most applications is well worth the overhead. However, my personal observation is that memory management for most objects is trivial, and maybe 10%-20% of them account for the need for kludges such as reference counting and really complicated memory management schem...

Will new return NULL in any case?

I know that according to C++ standard in case the new fails to allocate memory it is supposed to throw std::bad_alloc exception. But I have heard that some compilers such as VC6 (or CRT implementation?) do not adhere to it. Is this true ? I am asking this because checking for NULL after each and every new statement makes code look very u...

Does this C++ class containing a variable size array use dynamic memory allocation?

Does doing something like this use dynamic memory allocation? template <class T, int _size> class CArray { public: ... private: T m_data[_size]; }; Can someone explain to me what's going on behind the scenes when I create the object? CArray<SomeObject, 32> myStupidArray; ...

Finding Memory Usage in Java

Following is the scenario i need to solve. I have struck with two solutions. I need to maintain a cache of data fetched from database to be shown on a Swing GUI. Whenever my JVM memory exceeds 70% of its allocated memory, i need to warn user regarding excessive usage. And once JVM memory usage exceeds 80%, then i have to halt all the da...

Loading new assembly when Serializing

I have a loop in a BackgroundWorker that saves some stuff via xml Serialization when needed but this seems to load a new assembly each time 'xxyyzz.Main.vshost.exe' (Managed): Loaded '9skkbvdl' 'xxyyzz.Main.vshost.exe' (Managed): Loaded 'd2k4bdda' and so on. Why is this happening? Is there any thing i can do about it? Is this...

Does this copy class method leak memory?

- (id)copyWithZone:(NSZone *)zone { PoolFacility *copy = [[[self class] allocWithZone:zone]init]; copy.name = [self.name copy]; copy.type = [self.type copy]; copy.phoneNumber = [self.phoneNumber copy]; //make sure I get proper copies of my dictionaries copy.address = [self.address mutableCopy]; copy.webAddre...

Getting a segfault (EXC_BAD_ACCESS) when deallocating variables

Ok I understand that this error mostly comes from sending a method call or trying to access a variable that has already been deallocated. Here is the problem: .h @interface TimeEntry : NSObject <NSCopying, NSCoding> { NSDate *from; NSDate *to; NSString *information; } @property (nonatomic, retain) NSDate *from; @property (nonatomi...

Why does my tomcat application's memory usage keep growing?

My application is running on Windows Server 2000. The memory usage keeps growing (from 145m). Is that normal? I am new to Java. The version is Tomcat5.5. ...

Retriving the retain count for a CGImageRef object?

While you can release a reference to a CGImageRef object using "CGImageRelease", which, according to the SDK this "decrements the retain count of a bitmap image", is there a way to inspect the current retain count for a CGImageRef instance? [cgImageRef retainCount] isn't valid since CGImageRef isn't a valid receiver of the retainCount m...

Standard .Net TDD Memory Test

Is it useful to write a standardised TDD [Test] method that would expose common memory issues ? The set of tests could be easily, quickly applied to a method and would red-fail 'classic' .NET memory issues but would green-pass the classic solutions. For example common memory issues could be : too much relocation by the garbage collec...