473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Proper Usage of Shared Memory

When I first discovered shared memory (between multiple processes) I
immediately started thinking of how to build my own VM subsystem +
locking mechanisms for a large single block of memory. This seems like
one option, the other appears to be just having each "object" you want
to share be a shared mem space to itself: allocate objects into a
defined shared mem space. But here you have many many objects being
shared. Having a VM subsystem would allow you to just allocate a large
contiguous chunk of memory and then rely on your program for allocation,
deallocation, spatial locality/coherence and all other matters.

Is this at all a wise idea? Is there any advantage over having a large
number of small shared memory objects? What overhead does having shared
memory objects incur?

Sometimes I think the answer comes down to one merely of locking: that
with a complex vm subsystem mapped on a single flat space you could tune
far better far finer grained locking for your system. How much more is
at stake than simply locking? Obviously difficulty of implementation is
a key factor, but what about technical advantages and disadvantages? is
there a penalty for having thousands of shared memory objects between a
collection of programs?

Myren
Jul 22 '05 #1
1 2088
myren, lord wrote:
When I first discovered shared memory (between multiple processes) I
immediately started thinking of how to build my own VM subsystem +
locking mechanisms for a large single block of memory. This seems like
one option, the other appears to be just having each "object" you want
to share be a shared mem space to itself: allocate objects into a
defined shared mem space. But here you have many many objects being
shared. Having a VM subsystem would allow you to just allocate a large
contiguous chunk of memory and then rely on your program for allocation,
deallocation, spatial locality/coherence and all other matters.
First off, this has nothing to do with the C++ language.
Probably a better newsgroup is news:comp.programming.

Is this at all a wise idea?
Maybe, maybe not. You'll have to check your operating system to see
how it handles the memory request. Some OSes already have virtual
memory, so when you allocate a contiguous chunk, it may not be in
phyiscal memory; or another task may be using that memory.

Is there any advantage over having a large
number of small shared memory objects?
Research the topic of "Memory Fragmentation".

What overhead does having shared memory objects incur?
The minimal overhead is using semaphores, signals or mutexes.
One must be sure that two tasks are not writing to the same
memory at the same time.

Sometimes I think the answer comes down to one merely of locking: that
with a complex vm subsystem mapped on a single flat space you could tune
far better far finer grained locking for your system. How much more is
at stake than simply locking? Obviously difficulty of implementation is
a key factor, but what about technical advantages and disadvantages? is
there a penalty for having thousands of shared memory objects between a
collection of programs?

Myren

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Murat Tasan | last post by:
hi, i have a java application that can be fairly memory intensive. so, when i run the program, i use the -Xmx option to prevent out of memory errors. in particular, i have been using -Xmx512m,...
2
by: Ember | last post by:
For once, I have a customer that is more concerned with reducing the memory usage than with increasing performance - a new direction in tuning for me. I'm looking at db2 agent processes on the...
4
by: PaulR | last post by:
Hi, We have a Server running SLES 8 and 3GB memory, with 1 DB2 instance and 2 active Databases. General info... DB2level = "DB2 v8.1.0.72", "s040914", "MI00086", and FixPak "7" uname -a =...
20
by: Philip Carnstam | last post by:
How come .Net applications use so much memory? Every application I compile uses at least 10 MB of memory, even the ones consisting of only a form and nothing else. If I minimize them though the...
8
by: Greg Merideth | last post by:
I've written a basic windows service to provide some helper xml functions for my web methods and even thou the service is only about 1k lines long with 1 timer, its mem usage is 10m and its vm mem...
35
by: Alex Martelli | last post by:
Having fixed a memory leak (not the leak of a Python reference, some other stuff I wasn't properly freeing in certain cases) in a C-coded extension I maintain, I need a way to test that the leak is...
3
by: ruben20 | last post by:
Hi: Our postgres database has tables with several million rows in a server running Red Hat 8.0 with 1GB of memory. Recently we are experiencing a low performance in the access to the server via...
2
by: Don Kelloway | last post by:
I'm a first-time user with PostgreSQL so please forgive my ignorance. I've purchased (and read) Practical PostgreSQL (O'Reilly) and PostgreSQL Essential Reference (New Riders). So far, so good. ...
1
by: Jenea Ciur | last post by:
Hi ! If I will make char* pHugeMemory = (char*)malloc( huge_number_of_bytes ); in some place of my program, and after some time my program will jump to other processing place, that won't...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.