Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (VoroneTZ, monk12, Quad), 829 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
More than One "File_Open_Read" - Problem? #466671
06/26/17 22:07
06/26/17 22:07
Joined: May 2005
Posts: 868
Chicago, IL
Dooley Offline OP
User
Dooley  Offline OP
User

Joined: May 2005
Posts: 868
Chicago, IL
Is it problematic to have more than one external file open at the same time?

I am using file_open_read to gather data for a saved level, then using another file_open_read to gather data for some specific objects in that level (which are saved in other files).

So while the first file is open, it will then open the second file to get info on the object, then it will close the second file and continue reading from the first.

In general it works, but I've noticed that errors seem to creep into the data once several of these objects have been saved and need to be loaded.

I am having trouble tracking down the source of these errors, but I just realized that having two files open may be a possible cause. The files have different names, and I'm using different variables to store the file handles.

I've noticed that this seems to be fine when I load the level after I restart the game, but if I'm loading the level from another level (returning to the previously saved level) the errors are more likely to creep in.

Re: More than One "File_Open_Read" - Problem? [Re: Dooley] #466672
06/26/17 22:12
06/26/17 22:12
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline
Serious User
jumpman  Offline
Serious User

Joined: Apr 2002
Posts: 1,246
ny
Is it possible for you to close the first file, open the second file, read and store the values you need in temporary areas, then reopen the initial file and continue reading? See if that works!

Re: More than One "File_Open_Read" - Problem? [Re: jumpman] #466673
06/26/17 22:44
06/26/17 22:44
Joined: May 2005
Posts: 868
Chicago, IL
Dooley Offline OP
User
Dooley  Offline OP
User

Joined: May 2005
Posts: 868
Chicago, IL
Thanks!

I will definitely try that, it just seems like the wrong approach to keep two files open like that anyway.

Re: More than One "File_Open_Read" - Problem? [Re: Dooley] #466674
06/26/17 23:02
06/26/17 23:02
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
You can have as many files open as you want(*), in fact, by default your application will already touch a bunch of files just from being opened. It's not uncommon for larger applications to have 50+ open file handles at the same time, so no, that's definitely not the source of your problems.

I would argue you should see about finding the bug in your code that is causing the data corruption. Chances are it will also show up with just one file open, just with a different configuration. And if that's not enough, keep in mind that NTFS is a horrible, horrible filesystem that uses one big lock so every filesystem access is extremely expensive. Definitely not something you want to do in real time.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: More than One "File_Open_Read" - Problem? [Re: WretchedSid] #466677
06/27/17 05:08
06/27/17 05:08
Joined: May 2005
Posts: 868
Chicago, IL
Dooley Offline OP
User
Dooley  Offline OP
User

Joined: May 2005
Posts: 868
Chicago, IL
@WretchedSid,
Yes, that's kind of what I was afraid of.

Every time I think I've figured out the cause, it turns out I'm wrong.

The annoying thing is that you have to play for quite some time for the problem to appear, so for a long time I thought it was working fine. I tested it and it worked, so hey, I kept adding new features etc...

Now that I have actual players, playing the game, the problem shows up.

Can you think of anything that might cause a local variable to be assigned strange numbers that I am not assigning to them? I'm thinking it might be some kind of memory leak, that kicks in after playing for some time...

Re: More than One "File_Open_Read" - Problem? [Re: Dooley] #466678
06/27/17 07:34
06/27/17 07:34
Joined: May 2005
Posts: 868
Chicago, IL
Dooley Offline OP
User
Dooley  Offline OP
User

Joined: May 2005
Posts: 868
Chicago, IL
I don't want to bog anyone down with my actual script, which is quite long and complicated, but what's happening is that when the game reads from a file, and it reaches the end of the file, it's supposed to read a zero "0".

However, sometimes, instead of a zero, it reads some strange random number. I have no idea why these numbers show up, instead of the zero.

Re: More than One "File_Open_Read" - Problem? [Re: Dooley] #466680
06/27/17 10:35
06/27/17 10:35
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Originally Posted By: Dooley
I don't want to bog anyone down with my actual script, which is quite long and complicated, but what's happening is that when the game reads from a file, and it reaches the end of the file, it's supposed to read a zero "0".

However, sometimes, instead of a zero, it reads some strange random number. I have no idea why these numbers show up, instead of the zero.
, have you tried error(myValueString); ?
Also when the weird number shows up, in your text file it still shows 0 right?

Last edited by Reconnoiter; 06/27/17 10:36.
Re: More than One "File_Open_Read" - Problem? [Re: Reconnoiter] #466694
06/27/17 21:51
06/27/17 21:51
Joined: May 2005
Posts: 868
Chicago, IL
Dooley Offline OP
User
Dooley  Offline OP
User

Joined: May 2005
Posts: 868
Chicago, IL
Okay, I am pretty sure I have a memory leak. When I play the game, each time it loads a new level, I can see the memory going down to a certain point, then it builds back up as the level gets loaded.

However, each time it does this, it drops down to a point slightly higher than the last time, so each level starts to use up more and more memory. Once it reaches a certain level, the crashes and errors start occurring.

This strange variable bug is just one of a few bugs that occur, but it is the one that occurs most often, so I thought I would deal with it first. However, now I can see that it just depends on what the game is doing once the memory reaches that high level.

@Reconnoiter - is error(myValueString) an A8 feature? I have A7 and the manual does not mention anything about it...

The text file does not show the strange numbers. It's happening when the function reaches the end of the file, so it should return 0 and end the function. This works fine, until, as I've found out, the memory use gets too high.

I will search for memory leaks here on the forum. If anyone knows about finding/detecting/isolating them, please let me know where to look.

Re: More than One "File_Open_Read" - Problem? [Re: Dooley] #466705
06/28/17 09:51
06/28/17 09:51
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Oops forgot you use A7, error() maybe is a A8 feature (search for "error" without quotes).

A few ideas where to look:
- since when do you have this leak? Try remembering the things you have added, especially pointer related and ent_remove / ptr_remove related and array etc.
- check if any pointer you use is not NULL (especially entity, panel and bmap pointers)
- check your arrays if you do not access anything outside of the array's limit/size (e.g. myArray[-1] , silly example I know grin ).
- check if you dont do anything complicated in your entity events (or if you forgot to do a wait(1); before e.g. doing a c_scan or spawn particles or such in an entity event )

Last edited by Reconnoiter; 06/28/17 09:52.
Re: More than One "File_Open_Read" - Problem? [Re: Reconnoiter] #466759
06/30/17 22:15
06/30/17 22:15
Joined: May 2005
Posts: 868
Chicago, IL
Dooley Offline OP
User
Dooley  Offline OP
User

Joined: May 2005
Posts: 868
Chicago, IL
I think I found my problem. Every time I create a certain map entity, the nexus goes up a bit. I can't believe I did not notice this.

I use ent_purge when removing the entity, but this does not seem to reduce the nexus. When it is created again, the nexus goes back further each time.

I think by using a model, instead of a map entity, this problem will be solved.

Or maybe there is a way to reduce the nexus when removing a map entity, so it will not build up?

Page 1 of 3 1 2 3

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1