Solved

ReadFile()" function is failing with error ERROR_NO_SYSTEM_RESOURCES

Posted on 2004-08-05
10
2,353 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
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

832 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