1 registered members (AndrewAMD),
600
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: How to keep track of Memory usage
[Re: Dooley]
#466704
06/28/17 09:41
06/28/17 09:41
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
Serious User
|
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
max_nexus : this is dependant on how much ram your target computer has correct? This will be a 32bit limit, correct? , I just check task manager for ram usage. Your game should be below 1400/1500 mb iirc (depends a bit per pc).
|
|
|
Re: How to keep track of Memory usage
[Re: Reconnoiter]
#466712
06/28/17 12:35
06/28/17 12:35
|
Joined: Apr 2002
Posts: 1,246 ny
jumpman
OP
Serious User
|
OP
Serious User
Joined: Apr 2002
Posts: 1,246
ny
|
New entities will always need memory, and if I know the budget, then I can work under it. If you can work under a budget, as well as purging memory, my understanding is that you shouldn't run into memory problems.
But of course it's not that easy. I can create a model using ent_create, see the d3d_texfree decrease. When I ent_purge and ent remove, that entity, I regain that d3d_texfree. This is good. But if I create a terrain, and ent_remove, and ent_purge, the d3d_texfree slowly increases....eventually giving me nexus too small (0) errors! So if I made a game and the player continually loads a new level, this could cause memory not to be cleaned...and eventually crash.
What should I do?
|
|
|
Re: How to keep track of Memory usage
[Re: Dooley]
#466723
06/29/17 07:43
06/29/17 07:43
|
Joined: May 2005
Posts: 868 Chicago, IL
Dooley
User
|
User
Joined: May 2005
Posts: 868
Chicago, IL
|
I have discovered something.
If you change an entities skin, use ent_setskin(); instead of ent_morphskin();
With ent_morphskin, it uses a string to load the bitmap. With ent_setskin, it uses a previously declared BMAP* pointer.
The difference is that you can only use bmap_purge on BMAP* pointers, not on strings. This has been my experience anyway.
Currently, I was able to load several entities, purge their entities and bitmaps and load more, and the "d3d_texskins" number stays fixed, it no longer creeps up as I add more entities...
I am still seeing overall RAM usage creeping up though, but not nearly as much as before. I believe there are some objects/entities that I have not yet purged properly, so I need to keep looking through my code...
Anyway, I hope some of this provides the info you're looking for. Let me know if you find out any more about this.
|
|
|
Re: How to keep track of Memory usage
[Re: Dooley]
#466788
07/03/17 01:58
07/03/17 01:58
|
Joined: Apr 2002
Posts: 1,246 ny
jumpman
OP
Serious User
|
OP
Serious User
Joined: Apr 2002
Posts: 1,246
ny
|
I can use models I guess. But why should that be a work around? Is every terrain considered a block of memory that cant be fully recovered? After doing this test: I can create an .mdl file using ent_create, then ent_purge and remove, and i can regain that memory the entity used up. But if I ent_create a terrain, and ent_purge and ent_remove, the texture memory is never fully recovered. A workaround here is just to have all your terrain placed within WED and never created. UPDATE: reloading a level (level_load), over and over again, with or without terrains is causing me to run out of memory
Last edited by jumpman; 07/03/17 02:30.
|
|
|
Re: How to keep track of Memory usage
[Re: Dooley]
#466796
07/03/17 06:00
07/03/17 06:00
|
Joined: May 2005
Posts: 868 Chicago, IL
Dooley
User
|
User
Joined: May 2005
Posts: 868
Chicago, IL
|
I am facing similar issues. It seems to be my "d3d_texbmaps" and d3d_texskins" that are stacking up with each level load.
I've created a smaller game which emulates the functions of my game in a hope to find out where the leak is coming from. So far no luck...
Each time I add a function to the smaller game to see how the memory gets handled, and so far the memory is reset on each level load. There is no stacking. However, if I keep adding functionality similar to my (big) game, eventually I'll either have a working game, or I'll discover exactly what's causing the problem.
Level_Load is "supposed" to clear out the memory, but there must be some limitation, or some loophole that allows memory to build up between loads. I will definitely follow up if I find the source of my leak.
UPDATE: Actually, I can reproduce this memory drain by loading a .wmb file into my level. It increases the overall RAM usage each time I load it, even if I purge and remove it from the level, and even after I load a new level.
|
|
|
Re: How to keep track of Memory usage
[Re: Dooley]
#466809
07/03/17 13:36
07/03/17 13:36
|
Joined: Apr 2002
Posts: 1,246 ny
jumpman
OP
Serious User
|
OP
Serious User
Joined: Apr 2002
Posts: 1,246
ny
|
Hey Dooley!
I did the same thing. In my main level, I deleted more and more objects, and spammed the level_load on the same level. If i deleted everything except the bare minimum to run my level, no memory was being stacked. After narrowing it down, i found out it was map entities causing the problem!!!!
These map entities (.wmb) are placed in the level to prevent certain nodes from seeing each other. If i had none of these map entities in the level, memory isnt stacked/leaked. But once i placed these .wmbs in the level and reloaded constantly, the memory would stack. After going into the .wmb file itself in WED, i recompiled with no shadows, along with a few other options I dont remember off hand and resaved the .wmb.
Loading the new compiled .wmb into my main level, I was able to reload constnatly without memory stacking.
Question: Why would baked shadows in a map entity (.wmb) cause memory to be unreleased in level_load??
|
|
|
Re: How to keep track of Memory usage
[Re: jumpman]
#466810
07/03/17 13:45
07/03/17 13:45
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
Serious User
|
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
Question: Why would baked shadows in a map entity (.wmb) cause memory to be unreleased in level_load?? , wouldn't suprise me if it was a bug. But aren't map entities fairly slow compared to models? (I think Sivan tested this once with this map builder) Perhaps its better to just switch to models completely or perhaps bake in lower resolution shadows so the crash is more rare as a (crappy) quick fix for now .
|
|
|
Re: How to keep track of Memory usage
[Re: Dooley]
#466824
07/04/17 02:44
07/04/17 02:44
|
Joined: Apr 2002
Posts: 1,246 ny
jumpman
OP
Serious User
|
OP
Serious User
Joined: Apr 2002
Posts: 1,246
ny
|
I was able to reload/restart the level. But the map_entities definitely stacked, in the shd column!! Which meant something was going on with the shadows. And once I changed the settings of the wmb file individually, the shd never stacked in level reload. I have no idea why
UPDATE:
spoke too soon. WMB map entities placed in the level are not really freed from memory when level_load is performed.
Last edited by jumpman; 07/04/17 03:29.
|
|
|
Re: How to keep track of Memory usage
[Re: jumpman]
#466864
07/05/17 01:13
07/05/17 01:13
|
Joined: May 2005
Posts: 868 Chicago, IL
Dooley
User
|
User
Joined: May 2005
Posts: 868
Chicago, IL
|
I have found another thing that seems to help. Instead of loading a level directly, and worrying about purging different entities with ent_purge, I've found that loading a blank level seems to clear the entities automatically. Then you can load the level you need next. Something like this: level_load("Blank.WMB");//load a blank level to clear entities wait(2);
proc_kill(16);//kill all ongoing processes if necessary
bmap_purge(bitmaps);//use this command to purge bitmaps //some of them need to purged separately or they fill up the //d3d_texbmaps memory - I think you can only purge bitmaps //that were declared with a BMAP* pointer
level_load("Next_Level.WMB");//load the next level wait(2);
On my smaller game, this is not necessary. The engine seems to handle purging memory very well. I'm sure there is something in my code (on the bigger game) that is causing these problems, but I have yet to find it. In the meantime, these techniques seem to keep the memory from stacking...
|
|
|
Re: How to keep track of Memory usage
[Re: DriftWood]
#466908
07/07/17 07:28
07/07/17 07:28
|
Joined: May 2005
Posts: 868 Chicago, IL
Dooley
User
|
User
Joined: May 2005
Posts: 868
Chicago, IL
|
I did not "spam load" my level. I'm not 100% sure what that means.
I don't know if you saw my comment about bmap_purge(), but it seems to be a good function that still works (in A7 anyway). It looks like it may have been replaced by ptr_remove, so that might work as well. But you will have to use these on the actual BMAP* image you want removed from memory. So, for instance, if your terrain has a BMAP* pointer for the texture you are using, you can bmap_purge it when you need to remove or change the terrain.
Also, if memory is an issue for you, consider switching to .dds textures if you are not already using them. In one afternoon I eliminated 264 mb of texture memory from my game. I plan to continue switching my textures over to .dds, but this has been a huge gain in my memory issue...
|
|
|
Re: How to keep track of Memory usage
[Re: Dooley]
#466968
07/10/17 23:54
07/10/17 23:54
|
Joined: Apr 2002
Posts: 1,246 ny
jumpman
OP
Serious User
|
OP
Serious User
Joined: Apr 2002
Posts: 1,246
ny
|
Hey dooley, by spam, I meant just quickly reloading the level constantly and watching if any memory stacks. I have switched over to DDS textures, and it definitely helps with keeping memory low. I wanted to eventually do this, but I guess its better to start now. In a test level, Im getting a texture memory overflow crash. This is done by creating A LOT of map entities, which increases the nexus. I know I shouldnt create that many entities in a real game, but with a nexus of 500, I wanted to see if I could reach the entity limit, as well as keep track of memory usage. I would like to know why the game would crash this way:
Last edited by jumpman; 07/11/17 00:00.
|
|
|
|