memory-allocation

How to get a specific memory address using C

For my bachelor thesis i want to visualize the data remanence of memory and how it persists after rebooting a system. I had the simple idea to mmap a picture to memory, shut down my computer, wait x seconds, boot the computer and see if the picture is still there. int mmap_lena(void) { FILE *fd = NULL; size_t lena_size; vo...

is there a limit for the number of sk_buffs in the kernel

Hi, I need to steal some SKBs in my NetFilter hook, and retain them for some time. Is there a limit in the kernel about how many SKBs can I use at a time? What are the consequences of having some 100,000 or even more SKBs held in my kernel module? I could avoid copying my packets two time if I can have many-many SKBs. Regards, Denes ...

How can I tell if an object is statically or dynamically allocated on the constructor?

I have an object that requires a slightly different construction wether it's instance is staticly or dynamically allocated. The object should only have a single default constructor. So having two constructors, one for each case, and having the user explicitly select the proper constructor is out of the question. Is there any proper way ...

Multiple Image Operations Crash iPhone App

I'm new to the iPhone App development so it's likely that I'm doing something wrong. Basically, I'm loading a bunch of images from the internet, and then cropping them. I managed to find examples of loading images asynchronous and adding them into views. I've managed to do that by adding an image with NSData, through a NSOperation, whic...

Allocate 2D Array on Device Memory in CUDA

How do I allocate and transfer(to and from Host) 2D arrays in device memory in Cuda? ...

Thousands of new 0 size objects being added to my net total every second, should I be worried?

I have just finished ridding my project of leaks, but there are still thousands of objects under the category "GeneralBlock-0". The number of net allocations is through the roof (its approaching a million as I type) but none of them are leaks and none of them have a size greater than 0 bytes. UPDATE & EDIT: QuartzCore is responsible f...

C++ new int[0] -- will it allocate memory?

A simple test app: cout << new int[0] << endl; outputs: 0x876c0b8 So it looks like it works. What does the standard say about this? Is it always legal to "allocate" empty block of memory? ...

C++ operator new, object versions, and the allocation sizes

Hi. I have a question about different versions of an object, their sizes, and allocation. The platform is Solaris 8 (and higher). Let's say we have programs A, B, and C that all link to a shared library D. Some class is defined in the library D, let's call it 'classD', and assume the size is 100 bytes. Now, we want to add a few members ...

reallocating list in python

Ok this is my problem. I am trying something like this: for i in big_list: del glist[:] for j in range(0:val) glist.append(blah[j]) Idea is to reset list and reuse it for next set of data points. The problem is for some reason if the first list had 3 points. Therefore it used glist[0] glist[1] glist[2] The next...

How do I use Loki's Small Object Allocator in Lua successfully?

I've read somewhere on here where someone recommended using Loki's Small Object Allocator for Lua to help improve allocation performance. I read through the section in 'Modern C++ Design' and I think I've got a good enough understand on using Loki for this, with the exception of not using the SmallObject - Lua just wants raw memory, so ...

Are there any conformant C++ compilers that will leak memory for PODS derived from PODS ?

Given: #include <iostream> using namespace std; struct Concrete { char name[20]; char quest[20]; char favorite_color[13]; }; struct Concrete_with_knobs : public Concrete { int knobs[100000]; }; Concrete * cradle() { return new Concrete_with_knobs; } void grave(Concrete *p) { delete p; } void tomb_of_the_unknown_allo...

Memory allocators

I want to make a virtual allocator using c++ on windows,, which allocate data on a file on the hard disk, to reduce physical memory usage when allocate large objects !.. I don't want to use system virtual memory with virtualAlloc.. . I want to create a file on the disk and use it to allocate the whole objects and then move the part or th...

Bug trying to add two strings with snprintf

I'm trying to add two strings with snprintf but apparently i dont know what i'm doing. Here is the code block: char * filename = NULL; (void)snprintf (filename, sizeof(filename), "%s/%s", PATH, FILE); I also tried: char * filename = NULL; (void)snprintf (filename, sizeof(PATH)+sizeof(FILE)+1, "%s/%s", PATH, FILE); PATH...

taocp, sequential allocation questions

hi all, i've run into few problems while working tacop 2.2.2 sequential allocations, repacking memory section at page 247. the subject is there are n stacks sharing a common area locations L0 < L < LX, initially we set BASE[j] = TOP[j] = L0 for 1 <= j <= n the goal is when overflow occurs while inserting or deleting elements with res...

Global memory management in C++ in stack or heap?

If I declare a data structure globally in a C++ application , does it consume stack memory or heap memory ? For eg struct AAA { .../.../. ../../.. }arr[59652323]; ...

Java nonblocking memory allocation

I read somewhere that java can allocate memory for objects in about 12 machine instructions. It's quite impressive for me. As far as I understand one of tricks JVM using is preallocating memory in chunks. This help to minimize number of requests to operating system, which is quite expensive, I guess. But even CAS operations can cost up t...

Shared libraries memory space

Does a c++ shared library have its own memory space? or does it share the caller process' one? I have a shared library which contains some classes and wrapper functions. one of this wrapper function is kinda: libXXX_construct() which initializes an object and returns the pointer to the said object. Once I use libXXX_construct() in a c...

ArcGIS crash on memory allocation in C#

Hi everyone, I am working on a custom tool for ArcGIS which will integrate with ArcView. The tool is developped using C# and basically connects to an SQL database, fetches data to a local data structure, performs a great deal of statistical analysis and then displays the results as a new layer. The crash happens during this code's exec...

C : Why do you specify the size when using malloc?

Take the following code : int *p = malloc(2 * sizeof *p); p[0] = 10; //Using the two spaces I p[1] = 20; //allocated with malloc before. p[2] = 30; //Using another space that I didn't allocate for. printf("%d", *(p+1)); //Correctly prints 20 printf("%d", *(p+2)); //Also, correctly prints 30 //although I did...

Releasing objects returned by method in Objective-C

Ok, I know the answer to this question should be obvious, but I need a little push in the right direction. I find myself writing a fair number of methods that follow the following pattern: -(NSThing*)myMethod{ NSThing *thing = [[NSthing alloc] init]; // do some stuff with the thing return thing; } My question is, how do I hand...