473,698 Members | 2,411 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 2101

"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
2045
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
1533
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
1910
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
3947
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
6715
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
1337
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
1542
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
1462
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
8612
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,...
1
8905
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8880
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...
1
6532
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
5869
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
4373
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
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3053
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
2
2342
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.