memory-management

Capture CPU and Memory usage dynamically

I am running a shell script to execute a c++ application, which measures the performance of an api. i can capture the latency (time taken to return a value for a given set of parameters) of the api, but i also wish to capture the cpu and memory usage alongside at intervals of say 5-10 seconds. is there a way to do this without effecting...

What is the difference between "new" and "malloc" and "calloc" in C++?

What is the difference between "new" and "malloc" and "calloc" and others in family? (When) Do I need anything other than "new" ? Is one of them implemented using any other? ...

Why does a Convencience Constructor or Object Factory have to care about releasing the Object?

Actually, if you use a method with "new", "create", "alloc" or "copy" in it's name, then you are responsible for releasing the object that is returned to you. BUT: Why do these methods make an call to -autorelease? Wouldn't this result in "over-releasing" the object? Lets say I get that object from such a method, and then I call -releas...

Is it right to say that methods whoose names contain new, alloc, create or copy do not autorelease the objects they create?

As far as I know, only the "convenience" methods return created objects with an -autorelease, so that the receiver is not responsible for the memory of that object. But because Apple says that when you use a method that has a name consisting of "new", "alloc", "create" or "copy", you're responsible for releasing the object that method re...

Differences between Objective-C 2.0 vs. CLR in regards to memory managmenet

I've been learning to develop applications on the cocoa touch platform. I've come a long way but one piece that I can't wrap my head around is memory management. I thought I'd take a route of comparison rather than trying to start from scratch. I can't find much on the difference between the CLR (.net) and Objective-C 2.0 so I'm wonder...

Do I need to call GC.KeepAlive(this) in my Dispose method?

In this question @Jon skeet referenced this old blog post by the authority Chris Brumme. I was wondering, do I need to follow all calls to GC.SuppressFinalize(this) with a GC.KeepAlive(this) to avoid weird race conditions where a finalizer can be invoked during the time a disposer is running in heavily multithreaded applications? If ...

Objective-C 2.0; Assigning a Property; Leaking Memory?

I'm still learning about Objective-C memory management. I'm trying to implement several simple classes in an example program that I'm building. As an example, say I have the following class definition: #import <UIKit/UIKit.h> @interface customViewController : UIViewController { customObject *myCustomObject; } @property (ret...

Information on N-way set associative Cache stides

Several of the resources I've gone to on the internet have disagree on how set associative caching works. For example hardware secrets seem to believe it works like this: Then the main RAM memory is divided in the same number of blocks available in the memory cache. Keeping the 512 KB 4-way set associative example, the main...

Are there any Caching Frameworks for Delphi?

Question: What Caching Frameworks available for Delphi and how well developed are they? If there aren't any then is there a widely-accepted way of achieving the same objective? Applicable to Win32 targeting versions of Delphi. Question Detail: The type of framework that I'm enquiring about exists largely in Web Development frameworks al...

iPhone Memory Management and Releasing

Here's a common practice I see often (including from a very popular iPhone developer book) In the .h file: @interface SomeViewController : UIViewController { UIImageView *imgView; } Somewhere in the .m file: imgView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; [imgView setImage:[UIImage imageName...

Whats the maximum memory that a Flash movie can use in a browser?

I need to store a lot of data coming in from a server into memory, so I have to write my memory-storage algorithms based on how much I can safely use without hanging up or crashing the browser. Is there any safe size limit like 1MB or 100MB, that contents of global variables should not exceed? ...

iPhone - Blank Screen when Switching VIews

I have an application that makes use of drill-down views, tabbars, etc. I'm also making use of the UIImagePicker, as well as Route-Me for mapping support. Normally, the application performs fine. However, I find that if I perform a lot of activities and then switch between views, I end up with a blank screen and my view is not drawn. ...

Usefulness of ArrayList<E>.clear()?

I was looking through the Java documentation, and I came across the clear() method of ArrayLists. What's the use of this, as opposed to simply reassigning a new ArrayList object to the variable? ...

Who is responsible for clearing up memory from image lists?

If I have a CImageList object (a simple wrapper around a HIMAGELIST), and I call: m_pImageList->Replace(...); http://msdn.microsoft.com/en-us/library/k10cwcdb.aspx Who is responsible for clearing up the memory? Does the image list create a copy of any bitmap I pass in (i.e. can I create a CBitmap object on the stack then pass the a...

Contigious Pages/Physical Memory in Java

My goal is to ensure that an array allocated in java is allocated across contiguous physical memory. The issue that I've run into is that the pages an array is allocated across tend not to be contiguous in physical memory, unless I allocate a really large array. My questions are: Why does a really large array ensure pages which are co...

Garbage Collection in C++/CLI

Consider the below: #include <iostream> public ref class TestClass { public: TestClass() { std::cerr << "TestClass()\n"; } ~TestClass() { std::cerr << "~TestClass()\n"; } }; public ref class TestContainer { public: TestContainer() : m_handle(gcnew TestClass) { } private: TestClass^ m_handle; }; void createContainer()...

How can I use a page table to convert a virtual address into a physical one?

Lets say I have a normal page table: Page Table (Page size = 4k) Page #: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Page Frame #: 3 x 1 x 0 x 2 x 5 x 7 4 6 x x x How can I convert an arbitrary logical address like 51996 into a physical memory address? If I take log base 2 (4096), ...

Reinitialize a view controller - iPhone

I have a multi view application with individual UIViewControllers and xibs. I have one view that is the game view and every time I call it I want it to re-initialize, by that I mean restart at it's initial condition and not in the state I last left it in. Here is the code block I am using to load and remove views: -(void)loadStartVi...

Hierarchical Memory allocator library for C++

My application is mostly organised in layers so I found that something like the APR memory pools would be the best way. While reading on SO about C++ placement new posts here & here, and a more generic C allocation question I was thinking about hand-crafting a hierarchical pool allocator as suggested in one post, but in the pure NYI tra...

What determines what is written to a C++ pointer when delete is called?

I have a pointer to a given class. Lets say, for example, the pointer is: 0x24083094 That pointer points to: 0x03ac9184 Which is the virtual function table of my class. That makes sense to me. In windbg, everything looks correct. I delete said pointer. Now at 0x24083094 is: 0x604751f8 But it isn't some random garbage, that ...