memory-allocation

When not to alloc and init an NSString

Whenever I need to create a new NSString variable I always alloc and init it. It seems that there are times when you don't want to do this. How do you know when to alloc and init an NSString and when not to? ...

Windows tcmalloc replacement with static linking

A C++ project encounter the memory fragmentation problem, and tried following: nedmalloc- Did not pass the stress test (crashed after 15 hrs), that means it works in the most of cases but not the all. And more memory usage than other allocators. jemalloc- Not ready for Windows? tcmalloc- Compiled with host code with static linking, bu...

Memory leak problem with DBExpress

Hi, I've a weird problem with my application, its memory usage goes up a few hundred megabytes at once every now and then and eventually the application freezes. The application is written with Delphi, it uses database, COM (for OPC) and TCP/IP. With FastMM I've got following the screen shot of memory usage. I'm not completely sure ho...

using file/db as the buffer for very big numpy array to yeild data prevent overflow?

Dear All, In using the numpy.darray, I met a memory overflow problem due to the size of data,for example: Suppose I have a 100000000 * 100000000 * 100000000 float64 array data source, when I want to read data and process it in memory with np. It will raise a Memoray Error because it works out all memory for storing such a big array in ...

How to create pool allocator for abstract base class in C++?

Have run into a bug with glibc's malloc(): http://sourceware.org/bugzilla/show_bug.cgi?id=4349 and am thinking a work around for now until updating to later version of glibc is to do pooled allocation for small objects that have many instances coming and going. The small objects are all derived from an abstract base class. I'd like to ...

Can someone help me understand how to allocate properly in c?

I don't think I properly understand how to allocate memory for what I want to do. I would like my program to store arguments from the command line into an array of stucts called Command which has char **args in it. for example if I run ./test.c echo hello : ls -l I want it to store it as this commands[0].args[0]= echo commands[0]....

In C, does using static variables in a function make it faster?

My function will be called thousands of times. If i want to make it faster, will changing the local function variables to static be of any use? My logic behind this is that, because static variables are persistent between function calls, they are allocated only the first time, and thus, every subsequent call will not allocate memory for ...

Static C string allocation question

Consider the following code: char* str = "Hello World"; memcpy(str, "Copy\0", 5); A segmentation fault occurs during the memcpy. However, using this code: char str[12]; memcpy(str, "Hello World\0", 12); memcpy(str, "Copy\0", 5); The program does not produce a segmentation fault. Does the problem arise from allocating the memory on...

How to map/plot locations like "5000 block of Q ave" or "200 block of 7th St"?

Block sizes vary wildly, so I can't just always round down, but it doesn't seem like the google maps API understands these kinds of locations. I considered trying to go half way: for example, get the location of 5050 Q Ave for the 5000 block of Q, but blocks are not a regular interval either, nor is spacing on a block constant. I'm pre...

static allocation in java - heap, stack and permanent generation

Hi all !! I have been lately reading a lot on memory allocation schemes in java, and there have been many doubts as I have been reading from various sources. I have collected my concepts, and I need you people to go through all of the points and comment on them. I came to know that memory allocation is JVM specific, so I must say before...

C Realloc error - "Assertion `ptr == alloc_last_block' failed!"

I'm writing a function in C that takes in a linked list and a predicate and returns an array containing all values of the linked list satisfying this condition. Here's the function: void **get_all_that(list_t *l, int (*pred)(const void *)) { void **vals = NULL; int i = 0; // Number of matches found const size_t vps = sizeof(...

WinDbg alternative to !dumpheap -type?

I got the following line from !dumpheap -stat 000007fee09d6960 441762 835293368 System.String I'm interested to find out what the 441 762 strings are used for. Doing a !dumpheap -type System.String would list all, or am I mistaken? How can I just analyze some of them? ...

Memory management - how best to initialise an instance declared in the header

I've read a few posts on this, but there's still one thing that's not clear for me. I know this might be rather a n00b question, but I've actually got rather far into development without quite grasping this fundamental issue. A symptom of being self taught I guess. You declare a variable in your header, like so: @interface SomeClass ...

Reducing the memory footprint of a function with a lot of autoreleased variables?

Hi, I'm still wrapping my head around some of the nuances of memory management in objective-C, and came up with the following case I'm unsure about: + (NSDecimalNumber*)factorial: (NSDecimalNumber *)l { NSDecimalNumber *index = l; NSDecimalNumber *running = [NSDecimalNumber one]; for (; [index intValue] > 1; index = [inde...

How to create a list or tuple of empty lists in Python?

I need to incrementally fill a list or a tuple of lists. Something that looks like this: result = [] firstTime = True for i in range(x): for j in someListOfElements: if firstTime: result.append([f(j)]) else: result[i].append(j) In order to make it less verbose an more elegant, I thought I wi...

What non-NULL memory addresses are free to be used as error values in C?

I need to write my own memory allocation functions for the GMP library, since the default functions call abort() and leave no way I can think of to restore program flow after that occurs (I have calls to mpz_init all over the place, and how to handle the failure changes based upon what happened around that call). However, the documentati...

ipad: Image loading and Memory management problem & crash of the app

hi all. I am having about 60 different images coming from the webservice.And I am storing it in a NSMutablearray. now when I load the image for the very first time , each image will consume about 0.5 to 1.5 mb of space of iPad. As I do have multiple images the memory consumption reaches very high and then application gets crashed. I a...

NSString does not have to be released in cellForRowAtIndexPath: method?

In order to set cell.textLabel.text in the cellForRowAtIndexPath method I alloc and init a string. If I release this string after setting cell.textLabel.text, then the program will crash after doing this several times. Why doesn't it crash the first time? Since the string was alloced and inited, doesn't it have to be released? Here's t...

Dynamically Growing an Array in C++

I have an array of pointers of CName objects. I have the following constructor which initializes my array to size one. Then when I add an object I grow the array by 1 and add the new object. It compiles fine, however when I try to print them I just get segmentation fault error. Can you look and see if I'm doing anything wrong? //cons...

Repeat alloc to same pointer - what happens ?

HI all, What happens if you repeat the following code more than once ? pointer * mypointer = [[object alloc]init]; Do you just increase the retain count of that object by one again ? Thanks, Martin ...