473,769 Members | 6,160 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Memory Question

Can i place variables or arrays in Disk instead of main memory........

Mar 27 '07 #1
12 1627
Clement wrote:
Can i place variables or arrays in Disk instead of main memory........
Whether you can or can't, there's no way to specify it in standard C.

What problem are you trying to solve?

--
Is it a bird? It is a plane? No, it's: http://hpl.hp.com/conferences/juc2007/
"You've spotted a flaw in my thinking, Trev" Big Al,/The Beiderbeck Connection/

Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England

Mar 27 '07 #2
On Mar 27, 7:40 am, "Clement" <jeba.r...@gmai l.comwrote:
Can i place variables or arrays in Disk instead of main memory........
You can write them to disk with fwrite() and read them with fread().
However, if you want to operate on them while they are on disk as
though they were in memory, then you will have to memory map them.
To find out how to memory map them (or even if it is possible to
memory map them) you will need to examine an operating system specific
newsgroup.

Mar 28 '07 #3

Chris Dollin wrote:
Clement wrote:
Can i place variables or arrays in Disk instead of main memory........

Whether you can or can't, there's no way to specify it in standard C.

What problem are you trying to solve?

--
Is it a bird? It is a plane? No, it's: http://hpl.hp.com/conferences/juc2007/
"You've spotted a flaw in my thinking, Trev" Big Al,/The Beiderbeck Connection/

Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England
i want to create a binary tree[size of 1GB] so i want to place it in
Disk instead of memeory.. and i need to access through pointers.. can i

Mar 28 '07 #4
Clement said:

<snip>
i want to create a binary tree[size of 1GB] so i want to place it in
Disk instead of memeory.. and i need to access through pointers.. can
i
Look up B+-trees in Knuth.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Mar 28 '07 #5
Clement wrote:
Chris Dollin wrote:
>Clement wrote:
Can i place variables or arrays in Disk instead of main memory........

Whether you can or can't, there's no way to specify it in standard C.

What problem are you trying to solve?

--
Is it a bird? It is a plane? No, it's: http://hpl.hp.com/conferences/juc2007/
"You've spotted a flaw in my thinking, Trev" Big Al,/The Beiderbeck Connection/

Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England
Snip signatures when responding, especially ridiculously long ones.
i want to create a binary tree[size of 1GB] so i want to place it in
Disk instead of memeory.. and i need to access through pointers.. can i
You can't do both in standard C (with C pointers). You'll have to give up
at least one of your criteria.

[1GB of what? The-here desktop machine has (fx:grope) 2Gb of memory; a one-
off 1Gb binary tree I could just read into a C program. You could just buy
more memory. (But remember who I work for ...)]

--
The second Jena user conference! http://hpl.hp.com/conferences/juc2007/
"Life is full of mysteries. Consider this one of them." Sinclair, /Babylon 5/

Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN

Mar 28 '07 #6
Chris Dollin <ch**********@h p.comwrites:
[1GB of what? The-here desktop machine has (fx:grope) 2Gb of memory; a one-
off 1Gb binary tree I could just read into a C program. You could just buy
more memory. (But remember who I work for ...)]
One of the places I work, I could file an Engineering Support
Services request online and in a few minutes a nice man would
show up with a handful of DIMMs and install them for me, no
questions asked. I imagine I could ask for 4 GB or so of RAM
before I'd need my manager to sign off on it.

But it's not normal, most of the time, to design software so that
it only runs efficiently with the latest and greatest and
highest-specced hardware. It's better, when you can, to make
your software work on the widest range of hardware that doesn't
require major algorithmic inconvenience.
--
Ben Pfaff
http://benpfaff.org
Mar 28 '07 #7
Ben Pfaff wrote:
Chris Dollin <ch**********@h p.comwrites:
>[1GB of what? The-here desktop machine has (fx:grope) 2Gb of memory; a one-
off 1Gb binary tree I could just read into a C program. You could just buy
more memory. (But remember who I work for ...)]

One of the places I work, I could file an Engineering Support
Services request online and in a few minutes a nice man would
show up with a handful of DIMMs and install them for me, no
questions asked. I imagine I could ask for 4 GB or so of RAM
before I'd need my manager to sign off on it.

But it's not normal, most of the time, to design software so that
it only runs efficiently with the latest and greatest and
highest-specced hardware. It's better, when you can, to make
your software work on the widest range of hardware that doesn't
require major algorithmic inconvenience.
I wasn't saying that the OP /should/ just go for more memory; just
pointing out that they're likely within the space of "do it all in
memory", if that's an available option. We don't know enough about
their context to know if it's realistic or not.

--
Yes, Virginia, there is a second Jena user conference: Palo Alto, Sep 2007.
"Anything can happen in the next half-hour." /Stingray/

Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN

Mar 28 '07 #8
In article <11************ **********@n59g 2000hsh.googleg roups.com>,
Clement <je*******@gmai l.comwrote:
>i want to create a binary tree[size of 1GB] so i want to place it in
Disk instead of memeory.. and i need to access through pointers.. can i
You could look to see if your system has functions for memory-mapping
a file (mmap() for example). But you will probably not be able to
guarantee that it is mapped at the same address in different runs of
the program, so it may well be more practical to use offsets rather
than pointers.

-- Richard
--
"Considerat ion shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Mar 28 '07 #9
"Clement" <je*******@gmai l.comwrote:

# i want to create a binary tree[size of 1GB] so i want to place it in
# Disk instead of memeory.. and i need to access through pointers.. can i

Use a memory mapped file. You can use pointer operations on the file
contents. Whether a file page is actually on disk or in memory becomes
the operating system concerns.

Alternatives are pure memory where you malloc nodes. You need to write
tree traversal functions to translate external representations and
in memory version; or to do your own paging by maintianing page frames
and using seeks, reads, and writes to shuffle active nodes in and out
of memory.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
A bunch of savages in this town.
Mar 28 '07 #10

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

Similar topics

32
3863
by: John | last post by:
Hi all: When I run my code, I find that the memory that the code uses keeps increasing. I have a PC with 2G RAM running Debian linux. The code consumes 1.5G memory by the time it finishes execution. But I do not think it needs so much memory. About 500M memory should be enough. I have following questions about memory leak. (1).If in my code I only define constructor for my class, and do not define destructor, will it cause memory leak?
6
2702
by: Fred Zwarts | last post by:
Hello, I am trying to debug some complex debug code. In order to track the use of dynamically allocated memory, I replaced the standard global new and delete operators. (Not for changing the memory allocation algorithm, but for gathering some statistics and to find memory leaks.) This seems to work. However, I noticed that my replacing delete operator is not called
20
3064
by: Jonas | last post by:
Hi, I'm 99 % sure that Standard C guarantees to do a memory move inside realloc() in case the new, returned memory block (address) is different than the original one. Can any C expert confirm this to me, please? Thanks, Jonas PS. I using C90, not C99--if it makes a difference.
8
2933
by: vikram | last post by:
i have series of questions 1.How a c program is loaded in memory i mean the whats is the structure that the code segment?? data segment?? 2.When you say const int *p; where is p stored in the memory?? what happens internal so that its a read only. 3. when declared volatile int *p where exactly in the memory it is stored.
30
3750
by: jimjim | last post by:
Hello, This is a simple question for you all, I guess . int main(){ double *g= new double; *g = 9; delete g; cout<< sizeof(g)<<" "<<sizeof(double)<<" "<<sizeof(*g)<<" "<<*g<<" "<<endl; *g = 111; cout<< sizeof(g)<<" "<<sizeof(double)<<" "<<sizeof(*g)<<" "<<*g<<" "<<endl;
18
2272
by: Ramasubbu Ramasubramanian XR (AS/EAB) | last post by:
What is memory leakage, could any one explain with sample code
25
2386
by: Zeng | last post by:
I finally narrowed down my code to this situation, quite a few (not all) of my CMyClass objects got hold up after each run of this function via the simple webpage that shows NumberEd editbox. My memory profile shows that those instances survive 3 rounds of GC collections - it's not what I expected. In my real code, CMyClass occupies big amount of memory and they all share one stance of another class that I don't have enough memory hold...
2
1374
by: Ashish | last post by:
hi all, I have been doing some performance testing of a asp_net website, to be hosted on a shared server .. as far as i understand every page when accessed first time is compiled and loaded in the memory of aspnet_wp , so that would mean more distinct pages more the memory consumed by aspnet_wp, this is good since it would mean serving compiled copy of the page , which is good for speed.. another understanding is that once a page is...
7
4692
by: toton | last post by:
Hi, I have a STL vector of of characters and the character class has a Boost array of points. The things are vector<Characterchars; and class Character{ private: array<Point,Npoints; }; Now are the memory layout is contiguous? i.e all the character resides side by side just like array, and all Points side by side insede the
9
4537
by: Hemal | last post by:
Hi All, I need to know the memory required by a c program. Is there any tool/utility which can give me the memory usage in terms of DATA segment, TEXT segment, BSS segment etc. I am working on linux platform and my target is ARM processor. But i guess it should not matter. Actually i need to know both RAM & ROM usage.
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7409
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5299
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.