Skip to main content
gamedev.net
🔒 Locked

ERROR_NO_SYSTEM_RESOURCES ???

Started by fathom88 Jan 7, 2005 at 7:20 AM 5 replies 3.3k views
Original Post
fathom88
fathom88
I'm having a problem with an ap. It writes out to a file. It runs fine for a while. Then it stops working. At the point it calls CreateFile, the func returns ERROR_NO_SYSTEM_RESOURCES. What causes this error (alot to ask; there's probably a million)? The app is constantly opening and closing the same file to write to it. However, the handle is being closed. The app's memory usage does not look too bad. Nothing extreme. Thanks for any help.
grekster
grekster
You'll probably have to post some source code if you want people to give you any useful help as at the moment yeah I think it could be anything. Also what language your using could be helpful:)
Quote: Original post by BosskIn Soviet Russia, you STFU WITH THOSE LAME JOKES!
fathom88
fathom88

char msg[256];
while(app_running)
{
if((hFile == NULL) && (MsgQueueCount > 0))
{

hFile = CreatFile(...., OPEN_ALWAYS);

PopMsgFromQueue(&msg);
WriteFile(hFile, msg..);


CloseHandle(hFile);

hFile = NULL;
}
}

Zahlman
Zahlman
OTOH, re-opening and closing the file every iteration of the main game loop may not be the smartest thing to do, even if it should work in theory :/
fathom88
fathom88
I wanted a user to be able to open the file via notepad while app was still running and writing to file. I tried to call CreateFile with different flags but couldn't get it to work. Notepad would give error message saying another app had access to file. Am I missing something? I agree it does not seem too good to constantly open and close.
iMalc
iMalc
I think you need to set dwShareMode to FILE_SHARE_READ in CreateFile so that you can open it in notepad while your app has it open.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.