Frank Barknecht wrote:
Hallo, Phil Stone hat gesagt: // Phil Stone wrote:
Attached is [maketime], a lovely little timer/stopwatch. I've long since lost track of who made it, so I'm sorry can't give you well-deserved credit here. At any rate, it creates *at least* one symbol per second (probably more, I'm not sure if each [makefilename] generates a new symbol, but I'm guessing it does). This makes me nervous, as I have no idea what the symbol table capacity is, or how to see how "full" it is. It seems likely that this abstraction would crash eventually.
A fix for this maketime would be to reuse the symbols ":00" ... ":59" for minutes and hours by using two [cnv] objects for these. Then you would be able to let the clock run for decades before you get into trouble with the symbol table.
I've pondered this, and can't figure out what you mean, unless you're suggesting having 60 canvases, one for each possible number?
I did re-work [maketime] a little. Attached is a version (called [ps-stopwatch] that adds some features and only creates one symbol per second (plus one per minute, plus one per hour); the original created six per second. The new one requires zexy's [makesymbol] (which can convert lists of numbers into a single symbol -- perfect for this application, but not in Vanilla-Pd, obviously).
Every table or receiver or route-selector etc. also is a symbol.
Yes, but except in some extreme examples of dynamic programming, this is a known quantity. My anxiety comes from the memory leak behavior of long-running patches that dynamically create symbols (anything that does any sort of string handling is in this category, usually). It would be so much better to have transient symbols for this sort of thing, but as Mathieu said, it sounds like this is not going to happen any time soon.
So while the implementation of the symbol table is suboptimal, in practice it's not something you need to worry about too much. At least it should not make you replace [route freq note] with [route 0 1] :-)
Just to see the magnitude of the issue, I made a little test patch (attached) called [symbol_pig]. It just creates symbols, very fast. A very rough measurement based on watching resident memory increasing in bash's top command indicates that (on OS X 10.4), a megabyte is used up for approximately every 32,000 symbols.
Phil
#N canvas 0 22 450 300 10; #X obj 109 47 metro 10; #X obj 146 80 + 1; #X obj 109 79 f 0; #X obj 109 117 makefilename %d; #X symbolatom 109 148 10 0 0 0 - - -; #X obj 109 23 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1; #X connect 0 0 2 0; #X connect 1 0 2 1; #X connect 2 0 1 0; #X connect 2 0 3 0; #X connect 3 0 4 0; #X connect 5 0 0 0;
#N canvas 788 73 273 360 12; #X declare -lib zexy; #X obj 1 1 cnv 15 156 30 empty $0-time_display 0:03:36 6 15 0 24 -1 -241291 0; #X obj 71 224 + 1; #X obj 37 223 f; #X msg 163 56 0; #X obj 163 1 loadbang; #N canvas 337 282 345 318 sec-to-time-symbol 0; #X obj 13 7 inlet; #X obj 14 291 outlet; #X obj 13 63 % 60; #X obj 231 95 int; #X obj 182 6 import zexy; #X obj 95 124 change -1; #X obj 95 72 / 60; #X obj 231 69 / 3600; #X obj 95 98 int; #X obj 13 34 t f f f; #X obj 231 121 change -1; #X obj 231 177 makesymbol %s; #X obj 95 208 list prepend; #X obj 14 237 list prepend; #X obj 95 150 % 60; #X obj 14 264 makesymbol %s:%02s:%02s; #X obj 95 177 makesymbol %02s; #X obj 13 89 list; #X obj 231 149 % 100; #X connect 0 0 9 0; #X connect 2 0 17 0; #X connect 3 0 10 0; #X connect 5 0 14 0; #X connect 6 0 8 0; #X connect 7 0 3 0; #X connect 8 0 5 0; #X connect 9 0 2 0; #X connect 9 1 6 0; #X connect 9 2 7 0; #X connect 10 0 18 0; #X connect 11 0 12 1; #X connect 12 0 13 1; #X connect 13 0 15 0; #X connect 14 0 16 0; #X connect 15 0 1 0; #X connect 16 0 12 0; #X connect 17 0 13 0; #X connect 18 0 11 0; #X restore 37 252 pd sec-to-time-symbol; #X obj 3 46 r $0-start; #X obj 124 1 bng 14 250 50 0 $0-start empty empty 17 7 0 10 -4034 -1 -1; #X obj 124 17 bng 14 250 50 0 $0-stop empty empty 17 7 0 10 -258113 -1 -1; #X obj 141 9 bng 14 250 50 0 $0-reset empty empty 17 7 0 10 -262144 -1 -1; #X obj 176 29 r $0-reset; #X obj 80 46 r $0-stop; #X msg 3 71 1; #X msg 80 71 0; #X obj 37 121 f 0; #X msg 199 130 -1; #X obj 113 223 symbol -:--:--; #X obj 37 150 metro 1000; #X obj 37 289 list prepend; #X obj 215 252 f $0; #X obj 163 81 t b b b f f b; #X msg 37 317 ; $1-time_display label $2; #X connect 1 0 2 1; #X connect 2 0 1 0; #X connect 2 0 5 0; #X connect 3 0 20 0; #X connect 4 0 3 0; #X connect 5 0 18 0; #X connect 6 0 12 0; #X connect 10 0 3 0; #X connect 11 0 13 0; #X connect 12 0 14 0; #X connect 13 0 14 0; #X connect 14 0 17 0; #X connect 15 0 1 0; #X connect 16 0 18 0; #X connect 17 0 2 0; #X connect 18 0 21 0; #X connect 19 0 18 1; #X connect 20 0 14 0; #X connect 20 1 16 0; #X connect 20 2 15 0; #X connect 20 3 2 0; #X connect 20 4 17 0; #X connect 20 5 19 0; #X coords 0 -1 1 30 158 32 1 0 0;