I have a map that relates integers to vectors (of objects). These vectors represent a set of tasks to perform. In order to reduce the amount of copying going on while using this map and vector I've set them up to make use of pointers.
std::map<int, std::vector<MyObject *> *> myMap;
During initialization of the class that holds myMap...
I have a Vista x64 machine with 6GB of RAM, and I'm attempting to test that a device driver functions properly when doing DMA to physical addresses above 4GB.
I've found the AllocationPreference registry key, which is supposed to "force allocations to allocate from higher addresses before lower addresses", but the page isn't clear wheth...
I'm developing a game with AS3 and AIR. I will have a large-ish quantity of images that I need to load for display elements. It would be nice not to embed all of the images that the game needs, thereby avoiding having them all in memory at once. That's okay in smaller projects, but doesn't make sense here.
I'm curious about strategies f...
I wonder what the -(void)viewDidUnload is good for. Could I not just relase everything in -dealloc? If view did unload, wouldn't -dealloc be called anyways?
...
In some code I sometimes see this:
@property (nonatomic, assign) NSObject *foo;
...
-(void)dealloc
{
self.foo = nil;
...
}
Is it really necessary to nil an object when it hasn't been retained? Won't this actually cause problems?
...
Can the following code cause a memory leak? Would using a StringBuffer actually improve memory usage?
A little background: A coworker has been pushing his theories on memory leaks, and this is code he has identified as being problem code (without doing any sort of profiling), which he claims can cause a memory leak. I disagree with this...
When, if ever, can delete and free be used interchangeably in C++?
My concern is as follows: Say there is an incorrect mixup in the use of malloc/free and
new/delete (not to mention new[]/delete[]). However delete and free doing the same thing
fortuitously so this goes uncaught in testing. Later this may lead to a crash in production.
...
For an IBOutlet UITextField, does it matter as far as memory management or other reasons how you clear the text value?
textFieldX.text = nil
or
textFieldX.text = @"";
In objective-c it is acceptable to message a nil object and @"" is a static NSString *. I'm not sure if every @"" points to the same object in memory or if it allocat...
After creating large objects and running out of RAM, I will try and delete the objects in my current environment using
rm(list=ls())
When I check my RAM usage, nothing has changed. Even after calling gc() nothing has changed. I can only replenish my RAM by quitting R.
Anybody have advice for dealing with memory-intensive objects wi...
I have an array, called x, whose size is 6*sizeof(float). I'm aware that declaring:
float x[6];
would allocate 6*sizeof(float) for x in the stack memory. However, if I do the following:
float *x; // in class definition
x = new float[6]; // in class constructor
delete [] x; // in class destructor
I would be allocating dynam...
I have a shared library (namely libXXX.so) with a cpp/h file associated.
They contains a number of function pointers ( to point to .so function entrypoint) and a class to wrap this functions as methods of the said class.
ie: .h file:
typedef void* handle;
/* wrapper functions */
handle okUsbFrontPanel_Construct();
void okUsbFrontPanel_...
I'm running a J2ME Application and run into some serious memory problems.
So I built in another step to clear the huge input string and process its data and clear it.
But it didn't solve the problem until I set input = null and not input = "".
Shouldn't it be the same in terms of memory management? Can somebody explain me the difference...
I'm aware that there is a realloc function that would allow me to resize the memory block (and it's paired with a free function). However, I'm trying to do the same to a c++ class with some member pointers allocated memory using new instead of realloc. Is there an equivalent keyword to realloc in c++ that would allow me to achieve the sa...
Given:
int i = 42;
int j = 43;
int k = 44;
By looking at the variables addresses we know that each one takes up 4 bytes (on most platforms).
However, considering:
int i = 42;
int& j = i;
int k = 44;
We will see that variable i indeed takes 4 bytes, but j takes none and k takes again 4 bytes on the stack.
What is happening here? I...
Here is code I am referring to.
// Person.h
@interface Person : NSObject {
NSString *firstName;
NSString *lastName;
}
@end
// Person.m
@implementation Person
- (id)init {
if (![super init]) return nil;
firstName = @"John";
lastName = @"Doe";
}
@end
// MyClass.m
@implementation MyClass
.....
- (NSArray *)getP...
I am having some problems with NSString retaining. My problem is that on the second function (runItem) it doesn't seem to picking up on the value of the item1. No matter what I set it to, it seems that it is just set to nil. I am programming for Cocoa (desktop, versus iPhone), and I haven't had this type of problem with NSString befor...
My app is using roughly 300mb. I checked all objects i created with new and wrote a using around it if it had a dispose interface. Now with the web browser control i visit rougly 450 pages all which have ads on them and many use ajax request so for sure more then 1k request.
Why is the app taking that much memory? i did notice i can cli...
Hi, I'm using the iPhone SDK 3.0, but I think this is a general misunderstanding of how things work w/ c & memory management.
I've overridden the viewWillAppear method like this
@implementation MyViewController
- (void)viewWillAppear:(BOOL)animated {
NSArray *items = [NSArray arrayWithOjbects:self.searchButton, self.trashCan, nil];
...
Is it possible to access the managed heap in a .NET application and e.g. enumerate the objects that are currently allocated there?
I know there are various tools out there that allow you to do that, but I would rather do this myself from code so that I can use it in automated tests, like for checking if everything is disposed and cleane...
For educational purposes, I am using cstrings in some test programs. I would like to shorten strings with a placeholder such as "...".
That is, "Quite a long string" will become "Quite a lo..." if my maximum length is set to 13. Further, I do not want to destroy the original string - the shortened string therefore has to be a copy.
The...