memory

How do you limit PHP memory usage when processing MySQL query results?

So I have a PHP page that allows users to download CSV for what could be a whole bunch of records. The problem is the more results the MySQL query returns, the more memory it uses. That's not really surprising, but it does pose a problem. I tried using mysql_unbuffered_query() but that didn't make any difference, so I need some other wa...

Clearing libcurl memory in C#?

Is there a way to just clear all memory in c sharp ? For example my program is being run one time and it has filled an array. Is there a function which could clean all memory before the 2nd run so that I do not need to clear all variables ? Edit: Including text of OP's answer below I am using libcurl in my program. I click run, libc...

Are .NET Applications naturally memory intensive?

I started to write a large application in C# for the first time in my life. I wrote sample module to test the idea behind my software. This module contained several dozen C# dictionaries and lists of objects that each had several members and properties. I was shocked that after initializing core objects it end up utilizing about 40MB ...

pointers and references question

#ifndef DELETE #define DELETE(var) delete var, var = NULL #endif using namespace std; class Teste { private: Teste *_Z; public: Teste(){ AnyNum = 5; _Z = NULL; } ~Teste(){ if (_Z != NULL) DELETE(_Z); } Teste *Z(){ _Z = new Teste; return _Z; } void Z(Teste *va...

Reading from SerialPort & Memory Management - C#

I am working on a program that reads in from a serial port, then parses, formats, and displays the information appropriately. This program, however, needs to be run for upwards of 12+ hours - constantly handling a stream of incoming data. I am finding that as I let my app run for a while, the memory usage increases at a linear rate - not...

Should I load everything in memory upon application start ?

I'm using VB.Net, and I have a set of data which I have to able to filter through fairly quickly. Basically, the program is like google sugest, but instead of a drop-down menu, I'm using a listbox. When a user enters a word, I compare the word using LINQ and filter those that contain the user's input. The data are all strings of variable...

How are bits stored in memory? (In chunks? Can there be bits of multiple sizes stored toghether?)

I used to think that each memory location contains 8, 16, 32 or 64 bits. So 0101 would be stored in an 8 bit machine as 00000101 (sign extended if it was negative). This was all fine and dandy until I wrote a program in java out of curiosity to find out some more inner workings of this system. The method in question looks like this: p...

UITabViewController memory management

Hi, I have an app which consists multiple tabs managed by the class derived from UITabBarController (the only reason I subclassed UITabBarConteroller is to handle shake event for all views). 3 views are from subclassed UIViewContentroller class, one view is UINavigationController which shows a table. In every single controller I have, in...

Does a one cycle instruction take one cycle, even if RAM is slow?

Hi! I am using an embedded RISC processor. There is one basic thing I have a problem figuring out. The CPU manual clearly states that the instruction ld r1, [p1] (in C: r1 = *p1) takes one cycle. Size of register r1 is 32 bits. However, the memory bus is only 16 bits wide. So how can it fetch all data in one cycle? ...

Why would you ever want to allocate memory on the heap rather than the stack?

Possible Duplicate: When is it best to use a Stack instead of a Heap and vice versa? I've read a few of the other questions regarding the heap vs stack, but they seem to focus more on what the heap/stack do rather than why you would use them. It seems to me that stack allocation would almost always be preferred since it is quic...

Memory issue in C#, normal use if dll is called by .Net app but astronomical if dll called from legacy app.

I have created dll in C# 3.5 which does some memory intensive matrix calculations where matrices get created and disposed a lot. Everything works fine if dll is called from .Net app but if it is called from C++ created app memory usage just climbs until the function that uses matrices is done. I guess there is a problem with a automatic ...

How to control the memory usage of processes spawned by a JVM

I am coding an application that creates JVMs and needs to control the memory usage of the processes spawned by the JVM. ...

Create new C++ object at specific memory address?

Is it possible in C++ to create a new object at a specific memory location? I have a block of shared memory in which I would like to create an object. Is this possible? ...

Meaning of "@far int* @near IntegerPointer;"

I have the following definition. far int* near IntegerPointer; Does this mean, a pointer placed in 'near' memory pointing to a integer placed in far memory area. Can anyone please clarify. ...

Memory usage of current process in C

I need to get the memory usage of the current process in C. Can someone offer a code sample of how to do this on a Linux platform? I'm aware of the cat /proc/<your pid>/status method of getting memory usage, but I have no idea how to capture that in C. BTW, it's for a PHP extension I'm modifying (granted, I'm a C newbie). If there are ...

Efficient algorithm for finding related submissions

I recently launched my humble side project and would like to add a "related submissions" section when viewing a submission. Exactly like what SO is doing here - see right column, titled "Related" Considering that each submission has a title and a set of tags, what is most effective (optimum result), most efficient (fast, memory friendly...

How do I read the PE header of a module loaded in memory?

I'm experimenting with memory access in .NET. At the moment, I have a managed program that starts an unmanaged process and retrieves the BaseAddress of one of its loaded modules (a DLL). What I would like to do is somehow read the PE header of the loaded module so that I can later retrieve the addresses of its exports. Unfortunately, I ...

How do I read the names from a PE module's export table?

I've successfully read a PE header from an unmanaged module loaded into memory by another process. What I'd like to do now is read the names of this module's exports. Basically, this is what I have so far (I've left out a majority of the PE parsing code, because I already know it works): Extensions public static IntPtr Increment(this I...

Is there a trick to save time building in Xcode when there are thousands of images?

I've been reading an article about caching images in iPhone OS, and they pointed out this code snippet: NSData *urlData = [NSData dataWithContentsOfURL:aURL]; When I do something like this, does the whole big image data get sucked into the memory? Or will the image data go into memory as soon as that urlData object is actually used? R...

Optimal way to free() a malloc'ed 2D array in C

Supposing I have a 2 dimensional array which was created with something like this, char **foo = (char **) malloc(height * sizeof(char *)); for(i = 0; i <= height; i++) foo[i] = (char *) malloc (width * sizeof(char *)); First of all, Is this even the right way to create an array like this?. The catch here is, 'height' and 'width' ...