Solved

ReadFile()" function is failing with error ERROR_NO_SYSTEM_RESOURCES

Posted on 2004-08-05
10
2,368 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Object Oriented Programming, C#, referencing, scoping. 13 103
youtube blocking politics 4 105
asp Google Map 2 93
Assignment from incompatible pointer type? 2 78
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
A short article about problems I had with the new location API and permissions in Marshmallow
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…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

710 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