473,748 Members | 8,779 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to manage the memory in C?

If the file is very huge, but it is needed to be read in the memory,
how to manage the memory,? Thanks for any comment.

Nov 21 '05 #1
5 2104

"yezi" <ye*****@hotmai l.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
If the file is very huge, but it is needed to be read in the memory,
how to manage the memory,? Thanks for any comment.


Determine the file's size (can be done by opening it
and reading, counting bytes until eof) then allocate
that much memory, and read it in. If the memory allocation
fails, then the whole file won't fit in memory. In that case
you can read what part will fit, then when done with it, read a
different sufficiently small part of the file into that same
memory. Repeat as necessary. (this is known as 'paging', and
is done automatically on systems which feature 'virtual' memory.)

-Mike
Nov 21 '05 #2
Would u mind recommand some books on memory allocation technique by C?
Thanks

Nov 23 '05 #3
"yezi" <ye*****@hotmai l.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
Would u mind recommand some books on memory allocation technique by C?
Thanks


I can't assess the quality of any source on this over another,
as I'm no expert in this field; so I'll just advise you to do
what I'd do in your situation:

http://www.google.com/search?hl=en&q...=Google+Search

-Mike
Nov 23 '05 #4
yezi wrote:
If the file is very huge, but it is needed to be read in the memory,
how to manage the memory,? Thanks for any comment.

You need to be more precise. What does 'very huge' mean? How much memory
is available to you? What do you mean by 'managing memory'.

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 23 '05 #5
yezi said:
If the file is very huge, but it is needed to be read in the memory,
how to manage the memory,? Thanks for any comment.


Read as little (from the file into memory) as possible but as much as
necessary. If "as much as necessary" is more than you can handle, find a
different algorithm.

For example, if you're right-justifying some text, you need only read one
line into memory at a time.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Nov 23 '05 #6

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

Similar topics

3
2047
by: Bob Bedford | last post by:
We are 3 persons contacting various potential clients/customers and also potential advertisers for our website. Each person work at home, and it becomes ever difficult to manage our contacts. Also we don't see what the others do. Does it exist something allowing to manage such contacts. Ideally, this should be put on a webserver, allowing each of us to build a client's database, and the contacts history (like the program called ACT! on...
5
1534
by: Laser Lu | last post by:
What doese Garbage Collection mean? And what is Managed Code? Any links to relevant articles or resources would be appreciated! -- Best regards, Laser Lu
0
1243
by: Earl Teigrob | last post by:
I am currently using native .net XML classes for managing my little key/value data storage requirements and they work great. I have created a simple class to abstract the XML and manage my key/value data requirements that saves me tons of time and works great. Now I need to use XML files to store and manage records as a flat file (no relational data) and was wondering which path would be best. Do the native ..net classes make this kind...
0
1914
by: Mattia | last post by:
************************************************** Manage image without exhausted memory ************************************************** Hi; I have a big problem. I must create a script that upload an image an then resize it, if width or height are more than 250px. Now, after upload an image (in this example I suppose that it's a JPEG image):
11
3955
by: seberino | last post by:
Suppose a C extension locally built an array of PyObject* 's as follows... my_array = malloc(n * sizeof(PyObject*)); for (i = 0; i < n; i++) { my_array = PyList_New(0); } Q1: Must I do a Py_DECREF(my_array) on all elements before exiting this C extension function? (What if
2
6717
by: Giuseppe | last post by:
Hi everybody, this is my first post in this group since it is from little time that I have begun to learn c++. My problem is to post a web form using the libcurl library. The form is at this address: http://it.mobi.dada.net/lostpassword.php end it isn't very complicated: <form method="post" action="/cgi-bin/hotw/sendpassword.chm">
0
1338
by: Arthernan | last post by:
I have an Active-X control provided by a vendor that will inadvertenly crash while processing. The good part is that I do have a way to save information routinely as it is processing in the event it crashes. From there I can start over and I can eventually finish the process. My problem is that at this stage I have been doing this manually, but now I have to come up with an automated solution. What I want is to have my program run, save...
4
1545
by: themadjester | last post by:
So, I have not really used vista, I mean I have used other peoples vista enough to tell that I don't feel that "OMG I NEED THIS" and I have used word 2007 which left me less than impressed and gave me a taste for what vista would be like, but everyone I know hates it, especially those who are using it. The biggest complaint I have heard is that it is slow. I remember when XP came out and everyone upgraded to a minimum 256 megs of ram, now...
10
1465
by: DeveloperDave | last post by:
Hi, I am trying to improve some code that I currently have. I have a simple class called RequestMessage e.g. class RequestMessage { public: RequestMessage();
0
8989
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
8828
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9367
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8241
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
6795
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
4599
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...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2213
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.