memory

What is the right way to allocate memory in the C++ constructor?

Which is the right way to allocate memory via new in the C++ constructor. First way in the argument list: class Boda { int *memory; public: Boda(int length) : memory(new int [length]) {} ~Boda() { delete [] memory; } }; or in the body of constructor: class Boda { int *memory; public: Boda(int l...

.net memory profiler that can profile remote machines

I own the Ants Profiler 4 which is great for performance / memory profiling. Unfortunately it only works on the local machine and I cannot attach to a running process. But I have a memory leak that only seems to occure on our production server. A windows console app written in vb.net runs fine with constant memory usage for several day...

How precise is Task Manager?

I have a C++ Application, when I observe Task Manger, it shows that applicaiton's memory usage increases gradually. I manually check my source code, and I used Visual Leak Detector for Visual C++ to find memory leak, but I couldn't find any. Is it 100% that there is a memory leak, and I couldn't find it or is there any possibility that ...

Having problems analyzing a .dmp with WinDBG

Hi All, I will start by saying this is the first time I have done anything with WinDbg so excuse my silly mistakes if that is the issue. My website has been using a lot of memory and after reading blogs and watching videos by Tess Fernandez I am trying to use WinDBG to analyze my dump file. The setup: My web server is a Windows 2008 6...

Diffrence between stack memory and heap memory

Possible Duplicate: What and where are the stack and heap Where is heap memory and stack memory stored?I mean where on the harddisk?what are the limits of their size? ...

memory size of Python data structure

How do I find out the memory size of a Python data structure? I'm looking for something like: sizeof({1:'hello', 2:'world'}) It is great if it counts every thing recursively. But even a basic non-recursive result helps. Basically I want to get a sense of various implementation options like tuple v.s. list v.s. class in terms of memory...

how to write a file without allocating the whole byte array into memory?

This is a newbie question, I know. Can you guys help? I'm talking about big files, of course, above 100MB. I'm imagining some kind of loop, but I don't know what to use. Chunked stream? One thins is for certain: I don't want something like this (pseudocode): File file = new File(existing_file_path); byte[] theWholeFile = new byte[file...

Finding the memory address of a loaded DLL in a process in C++

I've got a running process which is using 'Test.dll'. I would like to know the exact memory location of the start of Test.dll in memory, but can't seem to be able to. My main problem is that I need to write to an offset from this DLL, but I can't exactly type in Test.dll+some offset when I use Read/WriteProcessMemory. Any help would be...

Can the JVM max heap size be dynamic?

The JVM -Xmx argument lets one set the max heap size for the JVM to some value. But, is there a way to make that value dynamic? In other words, I want to tell the JVM "look, if you need it, just keep taking RAM from the system until the system is out." Two-part reason for asking: First, the app in question can use a really wide range ...

Does apple approve iPhone app with memory leaks?

I have some memory leak in my app which yet I cannot figure out why. If I release those objects the app crashes. Is it a problem to approve my app by apple? ...

How can I fix this memory leak

If I release the dueDate here I am having BAD_EXCESS in other place of my code. What am I doing wrong here? invoice is a core date object/entity here. NSDate *deliveryDate = [NSDate dateWithTimeIntervalSinceNow: - oneDayInSeconds * 7]; NSDate *dueDate = [[NSDate date] initWithTimeInterval:(NSTimeInterval) (oneDayInSeconds * 3) sinceDa...

What are out-of-memory handling strategies in C programming?

One strategy that I though of myself is allocating 5 megabytes of memory (or whatever number you feel necessary) at the program startup. Then when at any point program's malloc() returns NULL, you free the 5 megabytes and call malloc() again, which will succeed and let the program continue running. What do you think about this strategy...

How to manipulate data in byte[] fast?

I need to remove every fourth byte in the byte[] I have. Is there some built-in function that could help me to do that or do I have to loop over the array picking and moving each byte one by one? Similarly what what if I need to place 0 after every three bytes from byte[] is there a way to do this faster than manually? ...

How is malloc() implemented internally?

Can anyone explain how malloc() works internally? I have sometimes done strace program and I see a lot of sbrk system calls, doing man sbrk talks about it being used in malloc() but not much more. I'd really like to learn how malloc() works. Thanks, Boda Cydo. ...

Class Methods Used Many Times Cause Leaks?

Let's say I'm developing a game. I run the following class method thousands of times: NSBundle *bundle=[NSBundle mainBundle]; I do not create an autorelease pool and release the objects that call the above class method all the time. I create an object, it calls the above class method, I release it, and on, and on, thousands of times. ...

Memory Management Autorelease vs. Alloc Question

3 correlated questions: 1.Do the code snippets below provide the very same results in terms of memory? NSBundle *bundle=[[NSBundle alloc] init]; [bundle release]; bundle=nil; and NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init]; NSBundle *bundle=[NSBundle mainBundle]; [pool drain]; pool=nil; bundle=nil; 2.Why in NSBundle...

Number of Objects in Autorelease Pool

Is there any way to query the number of objects that reside in a given NSAutoreleasePool? This is really important for me, because in my game there are several loops and I need to know how effectively I'm autoreleasing my autoreleased objects. ...

How to correctly allocate memory for a structure in a function to return its value for later use and how to cast a structure into a pointer?

I'm currently self-studying C for mastering an university project. In that project we have several signatures given that we need to implement for solving our task. After several hours of trying to make some progress, I must admit that I'm totally confused about the return types of functions. I will show you some code: This is a structur...

Memory leaks in UICOLOR color with RGB method

Hi, I have to token the string and get a RGB values to make a UICOlor, below is the code, NSString* text = @"1.0,1.0,1.0"; NSArray *chunks = [text componentsSeparatedByString:@","]; return [UIColor colorWithRed:([[chunks objectAtIndex:0] floatValue]/256.0) green:([[chunks objectAtIndex:1] floatValue]/256.0) ...

MKMapview memory problem.Zooming-scrolling

Hello everyone, I am developing a mapview application.When i look to instruments i see no leak in my application which is good.But my problem is whenever user scrolls,zooms in,zooms out the map,default mapview starts to allocate memories of MBs.When my application reaches about 25-30 mb then map releases some data which is about 5-6 mb s...