memory-allocation

What is the memory footprint of a method intensive Java object?

Suppose I have a Java class that has 100K worth of method code containing NO variables, but only 20 bytes of attributes. I instantiate 1000 objects from this class. Have I consumed 100,000K of memory? Or only 100K + (20bytes * 1000)? Or something else altogether? ...

Managed C++: Strings in List is not passed back to caller

I have a C# .Net console application which calls a C++ .Net class library. However, when the following application is executed, the list becomes empty!!! If I remove the line as indicated in the comment next to it, the code works. I don't understand the reason for this. If I want to reallocate the memory for list in the C++ class libr...

CUDA allocating array of arrays

Hi, I have some trouble with allocate array of arrays in CUDA. void ** data; cudaMalloc(&data, sizeof(void**)*N); // allocates without problems for(int i = 0; i < N; i++) { cudaMalloc(data + i, getSize(i) * sizeof(void*)); // seg fault is thrown } What did I wrong? ...

Understanding NSS PK11_CipherOp and C memory allocation

Hey all, Having some issues with C. I have this is my code: // First line works, second line does not! char outbuf[1024]; // char *outbuf = (char *) malloc(1024); // char is always 1 I am passing this outbuf to a method called PK11_CipherOp(), declared in the NSS library. The Documentation for this method can be found here, you ca...

alloca and ObjectiveC Garbage Collector

In an objective C project with GC enabled, I am allocating an array of variable size on the stack like this: MaValue *myStack = alloca((sizeof(id) * someLength)); (The reason why I want to do this is not important:) Then, within a loop, I push and pop stuff on/from myStack. Some of the things I push onto the stack are new objects that...

On the Design of zero-copy Memory allocators used in high volume fast-path code.

Disclaimer: please do not bother reading this long post unless you are an embedded programmer, or a kernel developer, or a high performance system software programmer. It is about memory allocators and might not be of any interest to you. I am building a library for high-volume high-performance same machine IPC, using OS specific pipes...

c++ destructor mess, impossible to debug...

Hello, when I run my program everything goes fine. At the end it prints out this: *** glibc detected *** ./streamShare: double free or corruption (fasttop): 0x08292130 *** ======= Backtrace: ========= /lib/tls/i686/cmov/libc.so.6[0xcc2ff1] /lib/tls/i686/cmov/libc.so.6[0xcc46f2] /lib/tls/i686/cmov/libc.so.6(cfree+0x6d)[0xcc779d] /usr/li...

Memory alignment on modern processors?

I often see code such as the following when, e.g., representing a large bitmap in memory: size_t width = 1280; size_t height = 800; size_t bytesPerPixel = 3; size_t bytewidth = ((width * bytesPerPixel) + 3) & ~3; /* Aligned to 4 bytes */ uint8_t *pixelData = malloc(bytewidth * height); (that is, a bitmap allocated as a contiguous bloc...

glDrawElements allocating memory and not releasing it

Using OpenGLES 1.1 on the iPhone 3G (device, not simulator), I do normal drawing fun. But at points during the run of the application I get giant memory spikes, after a lot of digging with instruments I have found that it is glDrawElements that is grabbing the memory. The buffer being allocated is 4 meg, which to me means its loading a ...

Marshal.AllocHGlobal VS Marshal.AllocCoTaskMem, Marshal.SizeOf VS sizeof()

Hi. I have the following struct: [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct WAVEHDR { internal IntPtr lpData; // pointer to locked data buffer internal uint dwBufferLength; // length of data buffer internal uint dwBytesRecorded; // used for input only internal IntPtr dwUser; // for c...

Vectored Exception Handling During StackOverflowException

If I've registered my very own vectored exception handler (VEH) and a StackOverflow exception had occurred in my process, when I'll reach to the VEH, will I'll be able to allocate more memory on the stack? will the allocation cause me to override some other memory? what will happen? I know that in .Net this is why the entire stack is com...

postgres memory allocation tuning

I've been reading a couple of docs regarding postgres memory allocation configuration but need a little help. my process runs thousands of SELECT SUM(x) FROM tbl WHERE ??? type queries, some of which take 10-30 seconds to run. the combined total for these queries is multiple days in some cases. besides that, i have a few statements whi...

How might I overload the "new" operator to allocate memory from a secondary memory device?

I am looking for a syntax to allocate memory from a secondary memory device and not from the default heap. How can i implement it? Using malloc() would by default take it from heap... Surely there must be another way! ...

PHP [OOP] : Memory allocation for Inheritance

Please see the code bellow: class A { public x = 5; public y = 6; public z = 7; } class B extends A { public m = 1; public n = 2; } $a = new A(); $b = new B() From the above code let $a is allocating x amount of memory and $b is allocating y amount of memory; Now my question is which one is correct from bellow? ...

If I have a variable locally declared in a loop that creats a thread, is it safe to use that variable in the called thread, even after the next iteration of the loop takes place?

I have a question about variable scope and memory management in C. I am writing a program that listens for a socket connection and then launches a new thread to handle that client. The main while() loop can launch many separate threads. My question is this: If I don't use dynamic memory allocation [no malloc()], and instead have a va...

Why does Git.pm on cygwin complain about 'Out of memory during "large" request?

Hi, I'm getting this error while doing a git svn rebase in cygwin Out of memory during "large" request for 268439552 bytes, total sbrk() is 140652544 bytes at /usr/lib/perl5/site_perl/Git.pm line 898, <GEN1> line 3. 268439552 is 256MB. Cygwin's maxium memory size is set to 1024MB so I'm guessing that it has a different maximum memor...

GC collecting...what?

I am trying to optimize my engine (C# + SlimDX) to make as less allocations as possible (to prevent the GC from firing too often) using as guide a profiler that gives me where the garbaged object are generated. Its going pretty well (going down from like 20 MB garbaged every 5s to 8 MB garbaged every 1 minute and half (yep, it was very l...

java.lang.OutOfMemoryError: bitmap size exceeds VM budget - android - how many images?

Hi I am developing an android app and as I read all around and learned for myself, I cant have a lot of images on the screen at the same time or I will get an exception. The question is how many images or how many KB in images or how many layouts/images can I have at the same time in the screen. I know this is not the only thing that...

At what point is it worth reusing arrays in Java?

How big does a buffer need to be in Java before it's worth reusing? Or, put another way: I can repeatedly allocate, use, and discard byte[] objects OR run a pool to keep and reuse them. I might allocate a lot of small buffers that get discarded often, or a few big ones that's don't. At what size is is cheaper to pool them than to real...

Showing Large PNG image in an Adobe Air application

I've got a bare minimum Adobe Air application; it's basically a s:SkinnableContainer inside a mx:WindowedApplication. I have a 6000 x 9000 pixel PNG image (~3.20MB) that I want to show in the SkinnableContainer. Note that the s:SkinnableContainer is a tag from Flex 4 Beta3 (spark components). Background Before I explain the problem, a ...