-zone to prevent crashing
Moderator: InsideQC Admins
22 posts
• Page 2 of 2 • 1, 2
calloc clears the allocated memory to 0, malloc doesn't. The default behaviour of Z_Malloc is to clear to 0, and there are places in the code that assume it's been cleared to 0 (some I've found, some I no doubt haven't) so it's safer.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
just to clarify on above assumptions:
this is quakespasm 0.85.4, x64 (not 'stock' fq085)
this is with my own mod (not quoth)
a single pak file (or no pack file and just loose files)
it is not happening at consistent times, however, that could mean nothing as the mod itself is highly random.
maybe the default zone size is larger for quakespasm, because when i run with -zone 256, the engine crashes immediately on loading a map with:
Z_Realloc: failed on allocation of 49960 bytes
(Z_Reallloc, no Z_Alloc btw, not a typo)
this is quakespasm 0.85.4, x64 (not 'stock' fq085)
this is with my own mod (not quoth)
a single pak file (or no pack file and just loose files)
it is not happening at consistent times, however, that could mean nothing as the mod itself is highly random.
maybe the default zone size is larger for quakespasm, because when i run with -zone 256, the engine crashes immediately on loading a map with:
Z_Realloc: failed on allocation of 49960 bytes
(Z_Reallloc, no Z_Alloc btw, not a typo)
- necros
- Posts: 77
- Joined: Thu Dec 16, 2004 10:32 pm
Quakespasm 0.85.4 seems to have something different going on here ..
Quakespasm 0.85.4 is using a default of 384 KB instead of 256 KB.
- Code: Select all
#define PR_STRING_ALLOCSLOTS 256
static void PR_AllocStringSlots (void)
{
pr_maxknownstrings += PR_STRING_ALLOCSLOTS;
Con_DPrintf("PR_AllocStringSlots: realloc'ing for %d slots\n", pr_maxknownstrings);
pr_knownstrings = (const char **) Z_Realloc ((void *)pr_knownstrings, pr_maxknownstrings * sizeof(char *));
}
Quakespasm 0.85.4 is using a default of 384 KB instead of 256 KB.
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
Yeah, I spotted that and it seems a bit of an abuse of what is a fairly limited memory space to me. Allocating zone space for temp strings/etc (and basically any string from progs.dat ends up in the zone with the QS code) might not have been the best idea.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
when it comes to frik_file, you have to ensure that those strings are properly flushed at the end of each map.
map loading can just use heap - the qc will never try to free them anyway, although this may give 16+ bytes of overhead per allocation, it should at least be 64-bit safe.
zone memory is at least useful for ensuring that qc-accessible strings are in a known memory range, permitting the use of 32bit pointers in a 64bit address space. Its also useful for tagging regions for bulk freeing, should that be useful (it is with q2, where the gamecode's allocs are freed in one fel swoop, although this can be done as a tiny layer above malloc). Other than that, yeah, ditch the zone, its not thread safe anyway.
If you do want to keep it, there's no reason that you can't create multiple zone blocks, mallocing a new one when you run out, although that won't help with the 64bit-strings issue.
For debugging, valgrind is much much much more useful than sentinals and hacking your own mem allocators.
map loading can just use heap - the qc will never try to free them anyway, although this may give 16+ bytes of overhead per allocation, it should at least be 64-bit safe.
zone memory is at least useful for ensuring that qc-accessible strings are in a known memory range, permitting the use of 32bit pointers in a 64bit address space. Its also useful for tagging regions for bulk freeing, should that be useful (it is with q2, where the gamecode's allocs are freed in one fel swoop, although this can be done as a tiny layer above malloc). Other than that, yeah, ditch the zone, its not thread safe anyway.
If you do want to keep it, there's no reason that you can't create multiple zone blocks, mallocing a new one when you run out, although that won't help with the 64bit-strings issue.
For debugging, valgrind is much much much more useful than sentinals and hacking your own mem allocators.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
seems to be a totally quakespasm thing then.
i ran fq085 with -zone 256 (i know it's supposed to be default but just in case) and it was able to load everything fine.
since everyone's got huge gobs of ram anyway though, i'll just continue to suggest using -zone 2048 until you guys remove zone completely, or whatever.
thanks for clearing this up a bit more for me.
i ran fq085 with -zone 256 (i know it's supposed to be default but just in case) and it was able to load everything fine.
since everyone's got huge gobs of ram anyway though, i'll just continue to suggest using -zone 2048 until you guys remove zone completely, or whatever.
thanks for clearing this up a bit more for me.
- necros
- Posts: 77
- Joined: Thu Dec 16, 2004 10:32 pm
22 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 1 guest