#197 closed defect (fixed)
added 'persistent' bool flag in psMemBlock
| Reported by: | Owned by: | Paul Price | |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | PSLib SDRS | Version: | unspecified |
| Severity: | normal | Keywords: | |
| Cc: |
Description
I needed to add a bool flag to the psMemBlock called persistent (I inserted it
just before the endblock member).
It signifies if the memory block is to be considered a memory leak. The
problem is that things like the storage for things like the error stack, trace
levels, etc., were being flagged as memory leaks, but these things are not
user-level memory leaks at all, rather persistent data used internally in
psLib.
I added the two functions are well,
p_psMemGetPersistent(void* ptr);
p_psMemSetPersistent(void* ptr, bool value);
Change History (4)
comment:1 by , 22 years ago
comment:2 by , 22 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Updated the SDRS, following RHL's suggestion.
typedef struct {
const void* startblock; /< initialised to p_psMEMMAGIC
struct psMemBlock* previousBlock; /< previous block in allocation list
struct psMemBlock* nextBlock; /< next block allocation list
psFreeFcn freeFcn; /< deallocator. If NULL, use generic
deallocation.
size_t userMemorySize; /< the size of the user-portion of the
memory block
const psMemoryId id; /< a unique ID for this allocation
const char* file; /< set from FILE in e.g. p_psAlloc
const int lineno; /< set from LINE in e.g. p_psAlloc
pthread_mutex_t refCounterMutex; /< mutex to ensure exclusive access to
reference counter
psReferenceCount refCounter; /< how many times pointer is referenced
bool persistent; /< marks if non-user persistent data
like error stack, etc.
const void* endblock; /< initialised to p_psMEMMAGIC
} psMemBlock;
The element \code{persistent} indicates if the memory is to be used by
some non-user persistent data. This allows memory marked as
\code{persistent} to be ignored when identifing memory leaks with
\code{psMemCheckLeaks}. Private functions shall be provided to test
and set the value of \code{persistent}.
[...]
int psMemCheckLeaks(psMemoryId id0, psMemBlock *array, FILE *fd, bool
persistence);
If \code{persistence} is \code{false}, then only those
\code{psMemBlock}s not marked as \code{persistent} shall be considered
as memory leaks. If \code{persistence} is \code{true}, then all
\code{psMemBlocks} shall be considered as memory leaks.
comment:3 by , 22 years ago
| Keywords: | VERIFIED added |
|---|
Closing subsequent to release of SDRS-08, ADD-07.
comment:4 by , 22 years ago
| Keywords: | VERIFIED removed |
|---|

This sounds like a good idea. My only comment would be that we'd like to be able to
optionally include all of the persistent blocks in leak checking (maybe via an extra flag?);
I can imagine times when we'd simply want to see all the memory, even the stuff that
someone thought should be peristent.