memory-management

How can I find the exact amount of physical memory on Windows x86-32bit using Perl or any other language?

I need to know how much physical memory a windows machine has, using Perl. I've tried using Win32::SystemInfo. However this module states the following caveat: On Intel x86 computers with more than 2 GB and less than 4 GB of memory, the MemoryStatus function will always return 2 GB for TotalPhys. Similarly, if the total available me...

where can i learn about how memory management in java works?

what i'm looking for is what gets put into the call stack once a function is called recursively, how the arguments are laid on top of each other (are local variables pushed in order? are paremeters pushed in the reverse order?), what bytes exist in an array besides those you asked to have for... searching on the internet, i've only fou...

Does this type of memory get allocated on the heap or the stack?

In the context of C++ (not that it matters): class Foo{ private: int x[100]; public: Foo(); } What I've learnt tells me that if you create an instance of Foo like so: Foo bar = new Foo(); Then the array x is allocated on the heap, but if you created an instance of Foo like so: Foo bar; Then it's created o...

iPhone Memory Debugging

I'm using Instruments to try to determine if there are places in my application that I could be more efficient with use of memory. I've taken the time to get somewhat familiar with Instruments but I'm generally a newbie with hunting memory management issues having come from a Java background. I seem to be using about 1.82mb by calls to t...

Autorelease iPhone

Coming up towards the end of developing an iPhone application and I'm wondering just how bad is it to use autorelease when developing for the iphone. I'm faced with some fairly random crashes and, so far, I can't pinpoint it to anything other than sloppy memory usage. As a Cocoa newbie I remember initially reading a guideline document ...

Why is it "impossible" to implement garbage collection in C because of weak typing?

I was told by a rather smart person that you cannot implement garbage collection in C because of it's weakly typed. The basic idea seems to be that C gives you too much freedom. He mentioned casting pointers without type checking... I don't really grok the idea. Can someone give me an explanation and possibly a code sample of why this w...

Returning a pointer to memory allocated within a function in Cocoa Objective-C.

In C, something like the following would be a disaster (ie, a memory leak) because you're returning a pointer to memory that you will never be able to free: NSString* foo() { return [NSString stringWithFormat:@"%i+%i=%i", 2, 2, 2+2]; } Is that in fact totally fine in Objective-C since the memory that the returned pointer points to w...

How to get the max sizes of the heap and permgen from the JVM?

I am trying to find out programatically the max permgen and max heap size with which a the JVM for my program has been invoked, not what is currently available to them. Is there a way to do that? I am familiar with the methods in Java Runtime object, but its not clear what they really deliver. Alternatively, is there a way to ask Ecl...

Performance counter for "Largest free region"?

I'm debugging an out-of-memory exception. When I get the exception, the "virtual bytes" performance counter indicates plenty of addressable space. The problem, however, is that the addressable space is badly fragmented, and the "Largest free region" (returned from !address in WinDbg) is too small. To measure the memory fragmentation, ...

Limit in the memory and cpu available for a user in Linux

Hello, I am a little concern with the amount of resources that I can use in a shared machine. Is there any way to test if the administrator has a limt in the amount of resources that I can use?. And if does, to make a more complete question, how can I set up such limit?. Thank you. ...

How to track memory allocations in C++ (especially new/delete)

How can I track the memory allocations in C++, especially those done by new/delete. For an object, I can easily override the operator new, but I'm not sure how to globally override all allocations so they go through my custom new/delete. This should be not a big problem, but I'm not sure how this is supposed to be done (#define new MY_NE...

About Memory Management in Java and C++.

Well, I've been given an assignment to basically figure out how memory allocation works for whatever language I'll be using. After some research, I have some questions and doubts which I'd like to get some insight in. For example: I read here that Java specifies exactly how the stack contents are organized. Looking at the JVM spec struc...

In the Dispose(bool) method implementation, Shouldn't one set members to null?

None of the guides/notes/articles that discuss IDisposable pattern suggest that one should set the internal members to null in the Dispose(bool) method (especially if they are memory hogging beasts). I've come to realize the importance of it while debugging an internal benchmark tool. What used to happen was that, there was this buffer ...

Newbie question about manual memory management and deep copying

Alright, so I'm trying out C++ for the first time, as it looks like I'll have to use it for an upcoming course in college. I have a couple years of programming under my belt, but not much in the non-garbage-collected world. I have a class, a Node for use in a doubly linked list. So basically it has a value and two pointers to other Node...

Memory Allocation/Deallocation Bottleneck?

How much of a bottleneck is memory allocation/deallocation in typical real-world programs? Answers from any type of program where performance typically matters are welcome. Are decent implementations of malloc/free/garbage collection fast enough that it's only a bottleneck in a few corner cases, or would most performance-critical softw...

Turning off the D garbage collector

I'm a C++ programmer thats considering using D for a personal project I want to play around with. I was wondering if there's a way to completely disable the garbage collector, and what the risks are of doing so. I know I can manage my own memory by overriding new and delete to use malloc and free, but if I did that I'd rather the gar...

Have you ever obtained a significant speedup by using boost::pool ?

I've played with boost::pool a few times in places where it seemed to me I was seriously hammering the heap with a lot of object "churn". Generally I've used boost::object_pool, or boost::pool_alloc as an STL template parameter. However the result is invariably that performance is virtually unchanged, or significantly worsened. I'm cu...

Memory management in memory intensive application

If you are developing a memory intensive application in C++ on Windows, do you opt to write your own custom memory manager to allocate memory from virtual address space or do you allow CRT to take control and do the memory management for you ? I am especially concerned about the fragmentation caused by the allocation and deallocation of ...

iPhone development - preventing leaks

Hi When I run my app with Leaks and view the Extended Details for any of the leaks, it takes me to a particular line in my code, but I don't know what to do after that! For instance, Leaks shows a malloc at this line NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; But I do no...

Verifying that memory has been initialized in C

I've written an API that requires a context to be initialized and thereafter passed into every API call. The caller allocates the memory for the context, and then passes it to the init function with other parameters that describe how they want later API calls to behave. The context is opaque, so the client can't really muck around in the...