473,394 Members | 1,706 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,394 software developers and data experts.

can my program requires 4GB memory in debian?

hi currently i'm using a crawler called larbin to get some pages, it
hashes each url to an integer. This is not a good method comparing to
md5, however it's enough for me. Currently i set the hash value to be
a 31-bit integer, which is used to be the index of a bit string in
memory, thus needs 256MB memory. i have 4GB+ free memory, so my
question is can i call for 4GB memory in my program in c++? or sixteen
256MB arrays. What about 8GB??
Jan 5 '08 #1
3 1582
Note up front: the issues here, while they crop up on any system, have
pretty little to do with C per se, so you should rather take this to a
group dedicated to programming under Debian (Note that it's a name, thus
the capital letter, and that I'm assuming you are using Debian/Linux).
Lastly, asking about C++ in a C newsgroup shows that that you actually
didn't take the time to get familiar with Usenet behaviour of first finding
out what a group is about and what is considered on-topic there (search
for "Usenet etiquette"). Please do that before further postings to the
Usenet.

Xiaoning He wrote:
hi currently i'm using a crawler called larbin to get some pages, it
hashes each url to an integer. [...] Currently i set the hash value to be
a 31-bit integer, which is used to be the index of a bit string in
memory, thus needs 256MB memory.
Okay, so you have a bit for every 31-bit hash value that tells you if the
URL was e.g. already visited. While this works, this actually fails when
you have hash collisions. Depending on the way things are used, using a
hash map (or maybe even just a std::map<>, but that requires C++ which is
not the topic here) which works correctly even with hash collisions allows
this to work, though the overhead is bigger. I'd use that, until my
requirements actually say that the overhead is too large and that
collisions don't matter.

Now for a completely unrelated topic...
i have 4GB+ free memory, so my question is can i call for 4GB memory in
my program in c++? or sixteen 256MB arrays. What about 8GB??
The amount of allocatable memory depends on the available virtual address
space. For 32 bit Linux systems that is at most 2 or 3 GiB (I'm not sure
which, but I think it depends on some settings with which the kernel was
compiled), on 64 bit systems it is much larger. Note that not all this
memory must be backed up by RAM, so the amount of available RAM will not
affect if this works (rather, RAM+swap set the limit) but it will affect
how well it performs. Lastly, the amount of available contiguous memory
might be limited by the fragmentation of the virtual address space. This is
independent of the programming language but rather depends on the operating
system, so it's off topic here.

Uli

Jan 5 '08 #2
Xiaoning He wrote, On 05/01/08 11:51:
hi currently i'm using a crawler called larbin to get some pages, it
hashes each url to an integer. This is not a good method comparing to
md5, however it's enough for me. Currently i set the hash value to be
a 31-bit integer, which is used to be the index of a bit string in
memory, thus needs 256MB memory. i have 4GB+ free memory, so my
question is can i call for 4GB memory in my program in c++? or sixteen
256MB arrays. What about 8GB??
Firstly, this is comp.lang.c, C++ is a different language which is not
topical here. Secondly, in C it would depend entirely on the
implementation and I expect the same is try in C++, so you probably need
to ask in a group dedicated to your implementation rather than comp.lang.c++
--
Flash Gordon
Jan 5 '08 #3
On 1ÔÂ5ÈÕ, ÏÂÎç7ʱ51·Ö, Xiaoning He <hxn...@gmail.comwrote:
hi currently i'm using a crawler called larbin to get some pages, it
hashes each url to an integer. This is not a good method comparing to
md5, however it's enough for me. Currently i set the hash value to be
a 31-bit integer, which is used to be the index of a bit string in
memory, thus needs 256MB memory. i have 4GB+ free memory, so my
question is can i call for 4GB memory in my program in c++? or sixteen
256MB arrays. What about 8GB??
finally i decide to require 2GB memory. Sorry for some inappropriate
points, I hardly post a message on usenet(this one seems to be the
2nd) and i've only learned c, although this program written in c++ is
not too hard to understand. Thank you for answering my question.
Jan 5 '08 #4

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

Similar topics

7
by: devesh.agrawal | last post by:
Hi , this program does a segfault in g++3.2 onwards , works with g++2.95 , Any ideas are welcome , basically there is this instruction when compiled with -S option , call *%eax , where the one...
10
by: Nimit | last post by:
Hi, I wasn't sure which forum this post belongs to, so I've posted it to a couple forums that I thought may be appropriate. In giving me advice, please consider me a beginner. Below is a synopsis...
54
by: bnp | last post by:
Hi, I took a test on C. there was an objective question for program output type. following is the program: main() { char ch; int i =2;
10
by: bear | last post by:
hi all, I have a program whose speed is so strange to me. It is maily used to calculate a output image so from four images s0,s1,s2,s3 where so=(s0-s2)^2+ (s1-s3)^2. I compile it with gcc (no...
14
by: Henk | last post by:
Hi Guys, (see actual code below) I wrote a little program that is supposed to read a file (input.txt) into memory (using a stack) and then reverse the file and display it to output. It works,...
41
by: SkyBlue | last post by:
Hi, can someone explain why the following simple C code segfaulted? I've stared it for 30mins but couldn't find the problem. Thx in advance #include <stdio.h> int main() { char *one; char...
19
by: Zytan | last post by:
I want multiple instances of the same .exe to run and share the same data. I know they all can access the same file at the same time, no problem, but I'd like to have this data in RAM, which they...
14
by: mark | last post by:
Hi there, I need to extract data from text files (~4 GB) on this data some operations are performed like avg, max, min, group etc. The result is formated and written in some other text files...
8
by: Horacius ReX | last post by:
Hi, I am developing some code in C which first I compile on my linux machine and afterwards I test on another special hardware which has almost no debug capabilities at all. Usually I get a lot...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.