memory

Tomcat Session Eviction to Avoid OutOfMemoryError

We are running a vendor-supplied webapp in Tomcat 5.5 using the StandardManager for sessions (in memory). As sessions can get quite large (20M+), running out of heap space is a serious concern. Users want to keep sessions around for a couple of hours if possible but would rather evict sessions than run out of heap space. It does not a...

c free question

Is this okay to do in c? int *i; // do stuff i = NULL; i = (int *) some_func(); // do stuff if (i != NULL) free(i); i = NULL; // do stuff i = (int *) some_func(); // do stuff if (i != NULL) free(i); i = NULL; ...

Sharing memory between two processes (C, Windows)

Since I haven't found an answer to the question asked previously here I'm trying a different approach. Is there any way to share memory between two processes? The second process gets the information from an injection since it's a legacy program that it's not being supported anymore. My idea is to inject some code there, in the struc...

Throttling CPU/Memory usage of a Thread in Java?

I'm writing an application that will have multiple threads running, and want to throttle the CPU/memory usage of those threads. There is a similar question for C++, but I want to try and avoid using C++ and JNI if possible. I realize this might not be possible using a higher level language, but I'm curious to see if anyone has any idea...

Memory location of enum value in C

I think I've read somewhere that it is illegal to take the address of an enum value in C (enum values not being lvalues; however, I can't find any information on this now). Is that correct and, if so, why? Edit: Here's an example that clarifies what I mean by "enum value" above. I mean taking the address of first_value below, not tak...

Technical name for a region of memory with a fixed pattern for bounds checking?

I want to know if there is some technical name for those regions of extra memory that are allocated for debugging purposes and filled with special patterns, so they can be checked at runtime to see if have been overwritten (and thus detecting a possible buffer overflow)... A fellow referred to them as "Canarios" (Canaries in Spanish), I...

How to manage large buffer in C++?

If I need a large buffer in my program written in C++, which one is better? Allocate the buffer in heap, and keep a reference to that buffer in the class that use it. Allocate a static buffer, and make it global. ...

64-Bit VB.NET Allocating > 2GB of RAM (.NET bug?)

I have a 64 bit VB.NET application and want to allocate a buffer > 2GB in size. In the following code both the "new" and the "ReDim" throw an "OverflowException." How can I allocate buffers > 2GB when these functions only accept signed 32 bit values? (Is this possible in C#?) Edit - I am running WinXP 64 with 4GB of RAM. Dim width ...

PostgreSQL consuming large amount of memory for persistent connection

I have a C++ application which is making use of PostgreSQL 8.3 on Windows. We use the libpq interface. We have a multi-threaded app where each thread opens a connection and keeps using without PQFinish it. We notice that for each query (especially the SELECT statements) postgres.exe memory consumption would go up. It goes up as high as...

Python subprocess.Popen erroring with OSError: [Errno 12] Cannot allocate memory after period of time

Note: This question has been re-asked with a summary of all debugging attempts here. I have a Python script that is running as a background process executing every 60 seconds. Part of that is a call to subprocess.Popen to get the output of ps. ps = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE).communicate()[0] After runn...

c++ memory allocation question

im trying to create an array: int HR[32487834]; doesn't this only take up about 128 - 130 megabytes of memory? im using MS c++ visual studios 2005 SP1 and it crashes and tells me stack overflow. ...

C: Function returning via void *

Coming from Java I'm confused by the use of Void allowing a return value in the following: void *emalloc(size_t s) { void *result = malloc(s); if (NULL == result) { fprintf(stderr, "MEMORY ALLOCATION FAILURE\n"); exit( EXIT_FAILURE ); } return result; } Is this returning a pointer to a chuck o...

Question about freeing memory in a php script

I just saw this in a script mysql_free_result($rawdb); I saw it on a script somewhere, it ran a mysql query and saved the results to an array, right after adding to the array, it ran that which I assume free's the memory used from the mysql query. I am just asking to verify, is it a good idea to do this? I have a couple mysql querie...

Keeping the contents of an array after its function call ends. (C++)

Lets say I have the following code. double *return_array(void) { double foo[2]; foo[0] = 5; foo[1] = 6; cout << foo << endl; cout << foo[0] << endl << foo[1] << endl; return foo; } double *bar = return_array() cout << bar << endl; cout << bar[0] << endl << bar[1] << endl; Now, bar and foo are still the same pointer ...

Calculating script memory usages in PHP?

Is it as simple as calling memory_get_usage() at the start and end of a script and subtracting the 1st from the second value, to get the total memory used on that script? If so, how can I convert that value to a more understandable number like kb and mb? ...

C# instantiate in foreach loop?

Possible Duplicate: Loops and Garbage Collection foreach (ObjectTypeA typea in ObjectTypeACollection) { var objectTypeAProcessor= new objectTypeAProcessor(); objectTypeAProcessor.Process(typea); } I found the above similar code where a collection of objects was being processed at the BLL and the DAL processor was called.Will ...

Difference between ByteBuffer.allocateDirect() and MappedByteBuffer.load()

Hi , I was trying to implement a sort of shared cache between two or more JVMs by memory mapping a particular file using MappedByteBuffer. From the specifications I see that when we use MappedByteBuffer.load() it should load the data into a direct buffer. I have a couple of questions on this. My code snippet:: RandomAccessFile file =...

How can I get the memory usage before, after and of an individual spawned process in Python?

I have spawned a process using: ps = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE).communicate()[0] I want to do 3 things: 1) Get the memory usage of the Python script before the call to subprocess.Popen 2) Get the memory usage of the Python script after the call to subprocess.Popen 3) Get the memory usage of the spawned ...

[Memory leak] - Not seeing stacktrace in Instruments

Hey Guys, I am using Instruments to find memory leaks in my iPhone application. I saw a few leaks in the application however the extended details view is not showing the stacktrace. It just says "No stack trace available for this block". I am sure I have missed some settings which resulted in this behavior. Any help would be greatly ap...

How to be more memory efficient with tab bars and nav controllers?

Background: I have a tab bar controller which currently contains 4 tabs. 3 of the tabs are navigation controllers which display a hierarchy of table views for viewing, editing, and creating data. The data is generally NSStrings that are taken from the user and stored in a global variable (data needs to be accessed from multiple views in ...