memory-management

Java: Allocate uninitialized block of memory?

Is there a way to allocate an uninitialized block of memory, such as an array that contains whatever garbage happened to be left behind, in Java? I want to do so to benchmark how fast Java's memory allocator/garbage collector can allocate/free blocks of memory. ...

How to clean up after using dojo ?

Hi, I have written an app using dojo that allocates a lot of data during its lifetime. Is there a way I can ensure that all the memory has been released when I am done? Is there a method like dojo.data.destroyAllStores() that I can use with the <body onunload> tag? Thanks. ...

iPhone development - memory release issue

Hi I am running into this issue of releasing an already released object but can't for the life of me find out where the error is taking place. I have added NSZombieEnabled flag and this is the log I get in gdb. Can someone please tell me how to go about resolving this issue or rather finding out where the error occurred. *** -[CFString...

Can you help me understand retain counts in cocoa/objective-c?

> .h file: NSString *myString; @property (nonatomic, retain) NSString *myString; > .m file: self.myString = [[NSString alloc] init]; If i'm not wrong i will end up with an NSString instance with retain count of +2. Right? I'm curious because Apple's example for Location uses "self." for initialization. Why? I checked and it does show...

.net Garbage Collection and managed resources

Is the memory from primitive data types (int, char,etc) immediately released once they leave scope, or added to garbage collection for later release? consider: For x as integer=0 to 1000 dim y as integer Next If this doesn't add 1000 integers to the garbage collector for clean up later, how does it treat string objects? would this cr...

How to get a CS paper published when not in academia?

I've implemented a newer GC algorithm and thought my findings could help. What should I do? Publish a blog? Do my best to write a paper and/or just start submitting abstracts to journals? I don't have any academic credentials myself. Should I start emailing local Professors to see if they could help me write it? Email professors w...

Why does MIcroQuill Smartheap throw "mem_bad_pointer" errors after I embed perl?

I am embedding perl in a C++ application that uses Smartheap. Regardless of whether I compile the perl to use its own malloc or the system's I get a bunch of error mem___bad_pointer dialogs. It seems to work fine when I just click "ok" and ignore the errors, but obviously I need to actually solve the problem. Do I maybe need to compil...

Is it acceptable not to deallocate memory

I'm working on a project that is supposed to be used from the command line with the following syntax: program-name input-file The program is supposed to process the input, compute some stuff and spit out results on stdout. My language of choice is C++ for several reasons I'm not willing to debate. The computation phase will be highly...

Is calloc(4, 6) the same as calloc(6, 4) ?

I'm a beginner C programmer, and I assumed that this would be the case, but would like some affirmation if possible. If they are the same, why not just take one argument instead? ...

Do memory deallocation routines touch the block being freed?

Windows HeapFree, msvcrt free: do they cause the memory being freed to be paged-in? I am trying to estimate if not freeing memory at exit would speed up application shutdown significantly. NOTE: This is a very specific technical question. It's not about whether applications should or should not call free at exit. ...

Out of Memory Exception

Hello, I am working on a web app using C# and asp.net I have been receiving an out of memory exception. What the app does is read a bunch of records(products) from a data source, could be hundreds/thousands, processes those records through settings in a wizard and then updates a different data source with the processes product informati...

What happens to the root view in UINavigationViewController when you push on a new view?

Specifically, what am I supposed to do with the view that is now hidden after pushing on a new view controller? In my situation I have a view with animations going on, that continue to execute after the view is off screen. Is there some accepted convention? Do I remove the View Controller and View from memory? Does Cocoa Touch have a co...

Virtual Memory

Most of the literature on Virtual Memory point out that the as a Application developer,understanding Virtual Memory can help me in harnessing its powerful capabilities. I have been involved in developing applications on Linux for sometime but but didn't care about Virtual Memory intricacies while I code. Am I missing something? If so, pl...

How to handle OutOfMemoryError in Java?

I have to serialize around a million items and I get the following exception when I run my code: Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOfRange(Unknown Source) at java.lang.String.<init>(Unknown Source) at java.io.BufferedReader.readLine(Unknown Source) at java.io.B...

Is Virtual Memory still relevant in today's world of inexpensive RAM?

Virtual memory was introduced to help run more programs with limited memory. But in todays environment of inexpensive RAM, is it still relevant? Since there will be no disk access if it is disabled and all the programs will be memory resident, will it not improve the performance and program response times? Is there any essential requi...

Best way to return list of objects in C++?

It's been a while since I programmed in C++, and after coming from python, I feel soooo in a straight jacket, ok I'm not gonna rant. I have a couple of functions that act as "pipes", accepting a list as input, returning another list as output (based on the input), this is in concept, but in practice, I'm using std::vector to represent...

Will Garbage Collected C be Faster Than C++?

I had been wondering for quite some time on how to manager memory in my next project. Which is writing a DSL in C/C++. It can be done in any of the three ways. Reference counted C or C++. Garbage collected C. In C++, copying class and structures from stack to stack and managing strings separately with some kind of GC. The community ...

How can I trust the behavior of C++ functions that declare const?

This is a C++ disaster, check out this code sample: #include <iostream> void func(const int* shouldnotChange) { int* canChange = (int*) shouldnotChange; *canChange += 2; return; } int main() { int i = 5; func(&i); std::cout << i; return 0; } The output was 7! So, how can we make sure of the behavior of ...

Freeing memory used by unattached DOM nodes in Javascript

As part of my application, I'm putting together a set of small Dom nodes that are not shown all at once. I'm storing them in an internal array. The user can invoke their display in which case I reparent them to the div that is used to display them. That's all well and good. But when it's time to replace all of them with new ones, I wa...

Memory management - should I worry about resizing a temporary array of long-lived objects within a state machine?

Garbage collection in .NET leads many to believe that lightweight objects can be treated as temporary. This seems especially true of arrays that hold object references to objects that are instantiated outside of the context of the array initialization. Consequently, it would seem that it should not really matter if a new array is in...