Solved

ReadFile()" function is failing with error ERROR_NO_SYSTEM_RESOURCES

Posted on 2004-08-05
10
2,360 Views
Last Modified: 2008-01-09
Hello Experts,

A call to the WIN32 "ReadFile()" function is failing with error ERROR_NO_SYSTEM_RESOURCES (1450).  I am assuming that I am running into some limitation on file handles, or internal file buffers or whatever, since when the error occurs 76 files have previously been opened (and remain open at the time of the error).

Is there a limit on how many files can be opened?  If yes, how can I get around the file limit problem in WIN32?

Thanks.
0
Comment
Question by:mohammadzahid
  • 3
  • 2
  • 2
  • +1
10 Comments
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 150 total points
ID: 11730099
I don't about an specific number of handlers you can open at a time, but it must be a high value (more than 76), but, if ReadFile() gives you an error, how could you opened the file? are you checking open function result?
Is it absolutely necessary to open 76 files at a time? I guess you have another alternative.
Also check your memory resources when opening files.
 
0
 
LVL 22

Accepted Solution

by:
cookre earned 200 total points
ID: 11730859
That error has many causes, the most common of which is running out of RAM.

Do you allocate lots of big buffers without releasing?
Do any recursion?
Do you have other big apps open?
If you're running this in debug mode from the compiler, make a release version and try it.

The once specific limit on file handles no longer obtains, rather, there's a limit on handles in general, for which there's a specific error code.
0
 
LVL 11

Author Comment

by:mohammadzahid
ID: 11731668
Thanks guys for the recommendations and help. I will try them and post questions if any.

Thank you.

0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 8

Assisted Solution

by:adg080898
adg080898 earned 150 total points
ID: 11742801
You are probably reading too much data at once. How many bytes are you asking to read in each ReadFile call? I know for sure that windows sockets have major problems with blocks more than 64KB in a single call. Disk drivers may have problems like this as well (with much more than 64KB of course).

Disk drivers may have limitations on how much data they can read in one shot. Perhaps the DMA hardware cannot handle so many pages in one scatter-read. Also, the disk cache can only lock-down a limited number of pages, so it might even be a software limitation.

Try keeping your reads definitely less than 16 megabytes, preferably less than 1 megabyte, in a single call.
0
 
LVL 8

Expert Comment

by:adg080898
ID: 11742803
Are you opening the file with FILE_FLAG_NO_BUFFERING? That asks for trouble...
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11925886
Still waiting for author's feedback
0
 
LVL 11

Author Comment

by:mohammadzahid
ID: 11926767
I have not had time to test the suggestions posted by the experts as I am extremely busy with a very important project.
I am anticipated to try the expert's suggestions in a week or 2.

Please do not clean or delete this thread for 2 weeks.





0
 
LVL 11

Author Comment

by:mohammadzahid
ID: 11999747
My application was reading too much data and was not deallocating buffer.
Problem resolved by reducing the number of file, reading small chuck of data into memory and free when not needed.

Points distributed evenly among experts as all of the responses provided a good lead to analyze and detect the source of the problem.

Thanks!!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
A short article about problems I had with the new location API and permissions in Marshmallow
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

827 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question