Skip to content
Snippets Groups Projects
Select Git revision
  • ab6f443930e2cb390a8fc53605b9d383c1538f24
  • master default protected
  • 9.0
  • marcus/wix3
  • 8.0
  • nt-tools
  • 7.8
  • 7.6
  • 7.4
  • 7.2
  • 7.0
  • 0.6
  • rosuav/latex-markdown-renderer
  • rxnpatch/rxnpatch
  • marcus/gobject-introspection
  • rxnpatch/8.0
  • rosuav/pre-listening-ports
  • rosuav/async-annotations
  • rosuav/pgsql-ssl
  • rxnpatch/rxnpatch-broken/2023-10-06T094250
  • grubba/fdlib
  • v8.0.2020
  • v8.0.2018
  • v8.0.2016
  • v8.0.2014
  • v8.0.2012
  • v8.0.2008
  • v8.0.2006
  • v8.0.2004
  • v8.0.2002
  • v8.0.2000
  • v8.0.1998
  • v8.0.1996
  • v8.0.1994
  • v8.0.1992
  • v8.0.1990
  • v8.0.1988
  • v8.0.1986
  • rxnpatch/clusters/8.0/2025-04-29T124414
  • rxnpatch/2025-04-29T124414
  • v8.0.1984
41 results

module.pmod

Blame
  • user avatar
    Martin Stjernholm authored
    More pain than they are worth.
    ab6f4439
    History
    module.pmod 2.01 KiB
    // $Id$
    
    #pike __REAL_VERSION__
    
    constant verify_internals = _verify_internals;
    constant memory_usage = _memory_usage;
    constant gc_status = _gc_status;
    constant describe_program = _describe_program;
    
    #if constant(_debug)
    // These functions require --with-rtldebug.
    constant debug = _debug;
    constant optimizer_debug = _optimizer_debug;
    constant assembler_debug = _assembler_debug;
    constant dump_program_tables = _dump_program_tables;
    constant locate_references = _locate_references;
    constant describe = _describe;
    constant gc_set_watch = _gc_set_watch;
    constant dump_backlog = _dump_backlog;
    #endif
    
    #if constant(_dmalloc_set_name)
    // These functions require --with-dmalloc.
    constant reset_dmalloc = _reset_dmalloc;
    constant dmalloc_set_name = _dmalloc_set_name;
    constant list_open_fds = _list_open_fds;
    constant dump_dmalloc_locations = _dump_dmalloc_locations;
    #endif
    
    #if constant(_compiler_trace)
    // Requires -DYYDEBUG.
    constant compiler_trace  = _compiler_trace;
    #endif
    
    //! Returns a pretty printed version of the
    //! output from @[memory_usage].
    string pp_memory_usage() {
      string ret="             Num   Bytes\n";
      mapping mu = memory_usage();
      foreach( ({ "array", "callable", "callback", "frame", "mapping",
                  "multiset", "object", "program", "string" }),
               string what) {
        ret += sprintf("%-8s  %6d  %6d (%s)\n", what, mu["num_"+what+"s"],
                       mu[what+"_bytes"], String.int2size(mu[what+"_bytes"]));
      }
      return ret;
    }
    
    //! Returns the number of objects of every kind in memory.
    mapping(string:int) count_objects() {
      int orig_enabled = Pike.gc_parameters()->enabled;
      Pike.gc_parameters( (["enabled":0]) );
    
      mapping(string:int) ret = ([]);
    
      object obj = next_object();
      //  while( zero_type(_prev(obj)) ) obj=_prev(obj);
      while(1) {
        object next_obj;
        if(catch(next_obj=_next(obj))) break;
        string p = sprintf("%O",object_program(obj));
        sscanf(p, "object_program(%s)", p);
        ret[p]++;
        obj = next_obj;
      }
    
      Pike.gc_parameters( (["enabled":orig_enabled]) );
      return ret;
    }