memory

What are uses of the C++ construct "placement new"?

I just learned about the C++ construct called "placement new". It allows you to exactly control where a pointer points to in memory. It looks like this: #include <new> // Must #include this to use "placement new" #include "Fred.h" // Declaration of class Fred void someCode() { char memory[sizeof(Fred)]; void* pla...

memory allocation in small memory devices

Some systems such as Symbian insist people to use heap instead of stack when allocating big objects(such as pathnames, which may be more than 512 bytes). Is there any specific reason for this? ...

How to translate a virtual memory address to a physical address?

In my C++ program (on Windows), I'm allocating a block of memory and can make sure it stays locked (unswapped and contiguous) in physical memory (i.e. using VirtualAllocEx(), MapUserPhysicalPages() etc). In the context of my process, I can get the VIRTUAL memory address of that block, but I need to find out the PHYSICAL memory addres...

How to allocate memory to an array of instances using an abstract class?

Hi, I have an abstract class defining a pure virtual method in c++: class Base { Base(); ~Base(); virtual bool Test() = 0; }; I have subclassed this with a number of other classes (which provide an implementation for Test()), which I'll refer to as A, B, C, etc. I now want to create an array of any of these types using this base cla...

Why is SQL Server not loading my index in memory?

I have a table that has 8 million records, with many fields, including lat/long values, and it has an index over the Lat/Long fields. I'm making a query to find the records that fall within a square around a point (to later refine into a circle), which is kind of: SELECT Lat,Long FROM Data WHERE (Lat BETWEEN 1 AND 2) AND (Long BETWEEN ...

When and why will an OS initialise memory to 0xCD, 0xDD, etc. on malloc/free/new/delete?

I know that the OS will sometimes initialise memory with certain patterns such as 0xCD and 0xDD. What I want to know is when and why this happens. When Is this specific to the compiler used? Do malloc/new and free/delete work in the same way with regard to this? Is it platform specific? Will it occur on other operating systems, suc...

Proper Memory allocation

I have the following construction: typedef struct bucket { char *key; ENTRY *data; struct bucket *next; } bucket; typedef struct { size_t size; bucket **table; } hash_table; But I have no idea how to allocate memory for that. I tried: hash_table* ht = malloc(sizeof(hash_table)*101); in order to create a hashta...

Best way for interprocess communication in C++

I have two processes one will query other for data.There will be huge amount of queries in a limited time (10000 per second) and data (>100 mb) will be transferred per second.Type of data will be an integral type(double,int) My question is in which way to connect this process? Shared memory , message queue , lpc(Local Procedure call) o...

How do I programmatically check memory use in a fairly portable way? (C/C++)

I'm writing cross platform C++ code (Windows, Mac). Is there a way to check how much memory is in use by the current process? A very contrived snippet to illustrate: unsigned long m0 = GetMemoryInUse(); char *p = new char[ random_number ]; unsigned long m1 = GetMemoryInUse(); printf( "%d bytes used\n", (m1-m0) ); Of course (m1-m0) sho...

Does large SQL Server Memory Usage cause errors?

Just started getting a bunch of errors on our C# .Net app that seemed to be happening for no reason. Things like System.IndexOutOfRangeException on a SqlDataReader object for an index that should be returned and has been returning for a while now. Anyways, I looked at the Task Manager and saw that sqlservr.exe was running at around 1,50...

What Simple Changes Made the Biggest Improvements to Your Delphi Programs

I have a Delphi 2009 program that handles a lot of data and needs to be as fast as possible and not use too much memory. What small simple changes have you made to your Delphi code that had the biggest impact on the performance of you program by noticeably reducing execution time or memory use? Thanks everyone for all your answers. M...

GC contains lots of pinned objects after a while.

I have a strange phenomenon while continuously instantiating a com-wrapper and then letting the GC collect it (not forced). I'm testing this on .net cf on WinCE x86. Monitoring the performance with .net Compact framework remote monitor. Native memory is tracked with Windows CE Remote performance monitor from the platform builder toolkit...

Out Of Memory using Postgres in Java

Hi. Well, we have a web app, running over JBoss and we're having an "OutOfMemory" error when trying to insert a lot of rows in several tables of a postgres DB. This is the complete environment for this error: * JBoss 4.3.x GA * Java 1.6.0 * Hibernate 3.0 * postgreSQL-8.3 (driver) About actual code-work environment: * The heavy part abou...

Purpose of memory alignment

Admittedly I don't get it. Say you have a memory with a memory word of length of 1 byte. Why can't you access a 4 byte long variable in a single memory access on an unaligned address(i.e. not divisible by 4), as it's the case with aligned addresses? ...

Where can one find a specification for the data structures representing a dll in memory?

Specifically I want to know what the data structure for the imports (idata) section looks like. ...

How do I do lots of processing without gobbling cpu?

I know the question title isn't the best. Let me explain. I do a TON of text processing which converts natural language to xml. These text files get uploaded fairly fast and thrown into a queue. From there they are pulled one-by-one into a background worker that calls our parser (using boost spirit) to transform the text into xml and lo...

Tracking memory usage in a tomcat webapp

Are there any good tools available to track memory usage In a tomcat java webapp? I'm looking for something that can give a breakdown by class or package. Thanks, J ...

Safe to uninstall .NET Framework 2.0 and 1.0 after installing 3.5?

I'm new to Windows development and I have a question. I'm using a Mac with Boot Camp to run Windows in dual boot, but I have an extremely small Windows partition (10 GB, because Boot Camp failed with bigger partition, due to the disk usage). After installing Visual Studio 2008 I continuously get low-disk-space warnings so I want to free ...

How to fix memory access error

Hi, I am working on a migration project, here we are migrating large set of C++ libraries from Mainframe to Solaris. We have complted migration sucessfully, but while running the application, some places it crashes with 'signal SEGV (no mapping at the fault address)'. Since the application supports on windows also, we checked with pur...

How can a program have a high virtual byte count while the private bytes are relatively low on Windows 32-bit?

I'm trying to get a better understanding of how Windows, 32-bit, calculates the virtual bytes for a program. I am under the impression that Virtual Bytes (VB) are the measure of how much of the user address space is being used, while the Private Bytes (PB) are the measure of actual committed and reserved memory on the system. In particu...