IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 4, 2011, 12:57:08 PM (15 years ago)
Author:
eugene
Message:

consolidate multiple FITTED stats; updates to psImageBackground based on results from MWV; added memory dump API

Location:
trunk/psLib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib

    • Property svn:ignore
      •  

        old new  
        3434*.bbg
        3535*.da
         36a.out.dSYM
  • trunk/psLib/src/sys/psMemory.c

    r30595 r31152  
    2727#include <string.h>
    2828#include <assert.h>
     29#include <unistd.h>
    2930
    3031#if defined(PS_MEM_BACKTRACE) && defined(HAVE_BACKTRACE)
     
    10901091    return (memBlock1->freeFunc == memBlock2->freeFunc);
    10911092}
     1093
     1094bool static dumpMemory = false;
     1095
     1096void psMemDumpSetState (bool state) {
     1097    dumpMemory = state;
     1098}
     1099
     1100void psMemDump(const char *name)
     1101{
     1102    if (!dumpMemory) return;
     1103
     1104    char filename[1024];          // don't make your sub-names too long!
     1105    static int num = 0;           // Counter, to make files unique and give an idea of sequence
     1106
     1107    snprintf (filename, 1024, "memdump_%s_%03d.txt", name, num);
     1108    FILE *memFile = fopen(filename, "w");
     1109
     1110    psMemBlock **leaks = NULL;
     1111    int numLeaks = psMemCheckLeaks(0, &leaks, NULL, true);
     1112    fprintf(memFile, "# MemBlock Size Source\n");
     1113    unsigned long total = 0;            // Total memory used
     1114    for (int i = 0; i < numLeaks; i++) {
     1115        psMemBlock *mb = leaks[i];
     1116        fprintf(memFile, "%12lu\t%12zd\t%s:%d\n", mb->id, mb->userMemorySize, mb->file, mb->lineno);
     1117        total += mb->userMemorySize;
     1118    }
     1119    fclose(memFile);
     1120    psFree(leaks);
     1121
     1122    // fprintf(stderr, "Memdump %s %d: Memory use: %ld, sbrk: %p\n", name, num, total, (void *) sbrk(0));
     1123    fprintf(stderr, "Memdump %s %d: Memory use: %ld\n", name, num, total);
     1124    num++;
     1125}
Note: See TracChangeset for help on using the changeset viewer.