I've read about Small-Object Allocation in "Modern C++ Design". Andrei Alexandrescu argues that the general purpose operators (new and delete) perform badly for allocating small objects.
In my program there are lot of objects created and destroyed on the free store. These objects measure more than 8000 bytes.
What size is considered sm...
Heya,
When I started programming in OpenCL I used the following approach for providing data to my kernels:
cl_mem buff = clCreateBuffer(cl_ctx, CL_MEM_READ_WRITE, object_size, NULL, NULL);
clEnqueueWriteBuffer(cl_queue, buff, CL_TRUE, 0, object_size, (void *) object, NULL, NULL, NULL);
This obviously required me to partition my data ...
I'm trying to get my head around memory management in Objective - C. I've used the garbage collector up until this point but before I go forward I'd like to get a better understanding of manually managing memory. I'm aware that I don't have an implementation of a dealloc method in this code.
My question is why does my inputString variab...
Take a variable length struct (if this were a real program, an int array would be better):
#include <vector>
struct list_of_numbers(){
int length;
int *numbers; //length elements.
};
typedef std::vector<list_of_numbers> list_nums; //just a writing shortcut
(...)
And build a vector out of it:
list_nums lst(10); //make 10 lists.
l...
How much memory or other resources is used for an individual VirtualAlloc (xxxx, yyy, MEM_RESERVE, zzz)?
Is there any difference in resource consumption (e.g. kernel paged/nonpaged pool) when I allocated one large block, like this:
VirtualAlloc( xxxx, 1024*1024, MEM_RESERVE, PAGE_READWRITE )
or multiple smaller blocks, like this:
Vi...
I encountered some strange memory leaks executing following code on iPhone device:
@implementation TestViewController
@synthesize myButton;
- (IBAction)buttonPressed {
ABPeoplePickerNavigationController* selectContactViewController = nil;
selectContactViewController = [[ABPeoplePickerNavigationController alloc] init];
sel...
I am having a java application and spawns lot of threads..and due to out of memory error..it dies if it runs for too much time.. Is there a jvm configuration parameter, that I can set so that it will wait for memory when no memory is available, instead of throwing out of memory error.
...
Hi All,
I have a thread function which allocates memory using malloc(). I kill the thread using pthread_kill without freeing the dynamically allocated memory.Will it be freed automatically once i call pthread_kill or there will be a leak?
...
The documentation for TB_GETBUTTONTEXT says that the handler has to return the number of characters and optionally (if lParam is not null) copy the string into the supplied buffer.
The caveat is that the length doesn't include the terminating character. I see the following problem. Say the handler stores the string precomputed (so its l...
My concern is the definition of buffer overrun. Looks like it only applies to writing outside the buffer.
But recently we found a spectacular bug when the program attempted to read from outside the legally allocated block of memory and ran into undefined behavior - either crashed with access violation or sent unrelated data across the ...
Hi, I had that question before, tried as answered, but still it does not work.
Before I allocated with:
imageArray_danceright = [[NSArray alloc] initWithObjects:
I came adviced to do like bellow, but now it crash immediatly after second anim is called:
//init areas:
imageArray_stand = [NSArray arrayWithObjects:
[UIImage imageWit...
I posted another question similar. This is my old code as some ppl say it would be even better, but there i didnt found a solution to release the allocated memory.
imageArray_danceright = [[NSArray alloc] initWithObjects:
[UIImage imageNamed:@"FrankieDanceRetime_0001.jpg"],
.. 40 images
[UIImage imageNamed:@"FrankieDanceRetime_00040.jp...
We're running to profile a java program on its memory usage. We have a 512 ram box and top shows that 500 or so MB of ram is used with very little free. However over at the RES column we can see that the jvm is only using 100MB or so. And all the other processes are not even significant (less than 1k). So what exactly is consuming all th...
I was recently going through a garbage collection article and decided to play along and attempt to gain a greater understanding. I coded the following, playing around with the using statement, but was surprised with the results... I expected e.Parent.Name outside of the using block to go ka-blooey.
What exactly is going on here?
static...
Is it somehow possible to use boost::object_pool<>::construct with non const references?
The following snippet doesn't compile (VS2010):
foo::foo(bar & b)
{
}
static boost::shared_ptr<foo> foo::create(bar & b)
{
return boost::shared_ptr<foo>(foo_pool.construct(b),
boost::bind(& boost::object_pool<foo>::destroy, & foo_pool, _1));...
The following program keeps crashing and I can't figure out what's wrong. It seems that v is somehow not available in the main function..
#include <iostream>
#include <vector>
using namespace std;
vector<string> *asdf()
{
vector<string> *v = new vector<string>();
v->push_back("blah");
v->push_back("asdf");
return v;
}
...
Whenever I first create a CTFont object it consumes about 10 MB of real memory.
CTFontRef font = CTFontCreateWithName(CFSTR("Helvetica"), fontSize, NULL);
CFRelease(font);
After calling CFRelease the memory consumption doesn't change so I'm assuming that some sort of font cache is built and stored. How can I make it consume less me...
I have a lot of memory allocations and the same number of FreeMem calls. What I didn't have though is a check before calling freemem to see if the pointer was nil, and a line after freeing to set the pointer to nil.
I tried to create a function to do this
procedure FreeMemAndNil(p: Pointer; size: Integer = -1);
begin
if p <> nil t...
Has anybody personally used
AfxEnableMemoryTracking function provided by MFC
to detect memory leaks. How useful is it?
...
Hey all, I have a problem and I'd like some advice.
I'm working on a document viewer that's composed of the following major parts:
zip library which unpacks the document container (minizip)
xml library which parses the document (libxml2)
UI code which renders the document on screen
Nothing too complicated or fancy.
On the emulato...