#File object number very high (over 1000), You sure of that?

Just starting out? Need help? Post your questions and find answers here.
User avatar
treebolt
User
User
Posts: 50
Joined: Thu Feb 21, 2008 4:38 pm
Location: Palm Harbor, FL

#File object number very high (over 1000), You sure of that?

Post by treebolt »

Using PureBasic 4.1

I get this error when I try to run my code and I use a number larger than 1000 for my #File parameter in OpenFile, etc.

If I make an EXE it will run fine

Why is this dangerous?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: #File object number very high (over 1000), You sure of t

Post by ts-soft »

If you use a number of 1000, PB allocates 1001 Objectstructures for the Fileobjects :!:
It is only a compilerwarning, you can ignore this, but it is better to use a small number
with Enumeration:

Code: Select all

Enumeration ;files
  #file1
  #file2
EndEnumeration
or use #PB_any.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
treebolt
User
User
Posts: 50
Joined: Thu Feb 21, 2008 4:38 pm
Location: Palm Harbor, FL

Re: #File object number very high (over 1000), You sure of t

Post by treebolt »

Thanks for the info

my program will sometimes open / lock more than 1000 files at a time. Is there any danger in doing this ?
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: #File object number very high (over 1000), You sure of t

Post by STARGÅTE »

you open / lock 1000 file in one time ?

if you lock it step by step you can use the same number for all, but close files befor open the next!!

or you #PB_Any to open many files
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
treebolt
User
User
Posts: 50
Joined: Thu Feb 21, 2008 4:38 pm
Location: Palm Harbor, FL

Re: #File object number very high (over 1000), You sure of t

Post by treebolt »

I want to keep the files locked so that they cannot be overwritten while the program is running. Even when I use #PB_Any when opening files it will sometimes reach a value greater than 1000 and the program will crash when trying to run it from PureBasic. It's getting annoying to have to create an EXE every time I want to test my program.

EDIT: Scratch it, I modified my program to use #PB_Any everywhere it tries to open / create a file and it's fine. I'm still curious as to why it's dangerous to use a number greater than 1000 or have more than 1000 files locked / open at a time. Seems like a crazy thing to cause a program to crash through the debugger.
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: #File object number very high (over 1000), You sure of t

Post by Shield »

:wink:

Code: Select all

DisableDebugger
OpenFile(2000, "file.txt")
EnableDebugger
Edit:
treebolt wrote:I'm still curious as to why it's dangerous to use a number greater than 1000 or have more than 1000 files locked / open at a time.
As ts-soft said it's unnecessary memory consumption.
Also, as far as I know, the maximum number of handles for files, windows etc. are limited by the OS.
Last edited by Shield on Fri Mar 16, 2012 6:08 pm, edited 1 time in total.
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
User avatar
treebolt
User
User
Posts: 50
Joined: Thu Feb 21, 2008 4:38 pm
Location: Palm Harbor, FL

Re: #File object number very high (over 1000), You sure of t

Post by treebolt »

Shield wrote::wink:

Code: Select all

DisableDebugger
OpenFile(2000, "file.txt")
EnableDebugger
Ahh, had no idea it was possible to disable the debugger through code. Pretty nifty.

Still, anyone know why it's 'dangerous' ? There has to be a reason this limitation exsists
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: #File object number very high (over 1000), You sure of t

Post by Shield »

See my edit...we should stop editing posts and just make double posts. :mrgreen:
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
Post Reply