Solved

ReadFile()" function is failing with error ERROR_NO_SYSTEM_RESOURCES

Posted on 2004-08-05
10
2,323 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
c# combobox autocomplete behavior 6 92
mergeTwo  challenge 13 72
mapBully challenge 6 89
Not needed 13 57
This article will show, step by step, how to integrate R code into a R Sweave document
A short article about problems I had with the new location API and permissions in Marshmallow
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now