post() memory leak?


    Jan 09 2008 | 2:29 pm
    While checking an external for memory leaks on Windows, I found that posting to the max window seems to allocate memory which is never freed. So I checked this using a standard "print" object, and it behaves the same. Maybe this is intended behavior, or maybe I'm just missing something, but I thought I'd mention it anyway. Just in case.
    Thijs

    • Jan 09 2008 | 6:47 pm
      Does the memory get allocated every time you post / print or just the first time? Does the allocated space continue to grow? If not, then it's just a lazy allocation of a shared resource.
      _Mark
      On Jan 9, 2008, at 6:29 AM, Thijs Koerselman wrote:
      > While checking an external for memory leaks on Windows, I found that > posting to the max window seems to allocate memory which is never > freed. So I checked this using a standard "print" object, and it > behaves the same. Maybe this is intended behavior, or maybe I'm just > missing something, but I thought I'd mention it anyway. Just in case. > > Thijs > > > #P window setfont "Sans Serif" 9.; > #P number 164 70 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; > #P window linecount 1; > #P message 164 89 164 9109513 sad fglkjg werlwerkj asdfsdf $1 $1 > $1; > #P newex 164 110 26 9109513 print; > #P window linecount 4; > #P comment 209 29 100 9109513 drag the value while watching the max > allocated memory in the taskmanager; > #P connect 2 0 1 0; > #P connect 3 0 2 0; > #P window clipboard copycount 4; >
    • Jan 09 2008 | 7:36 pm
      Hi Mark,
      I posted the little example patch to illustrate the issue. It has nothing to do with my external. I assume print internally uses post() to print to the max window, because it behaves identical to calling post() from my external. If you keep dragging the value up and down the allocated memory keeps increasing. Around 10kb per second.
      I just double checked on my intel mac and it behaves similar, looking at the activity monitor. I guess its not a bug then, but I don't understand why this happens.
      Thijs
      On Jan 9, 2008 6:47 PM, Mark Pauley wrote:
      > Does the memory get allocated every time you post / print or just the > first time? Does the allocated space continue to grow? If not, then > it's just a lazy allocation of a shared resource. > > _Mark > > On Jan 9, 2008, at 6:29 AM, Thijs Koerselman wrote: > > > While checking an external for memory leaks on Windows, I found that > > posting to the max window seems to allocate memory which is never > > freed. So I checked this using a standard "print" object, and it > > behaves the same. Maybe this is intended behavior, or maybe I'm just > > missing something, but I thought I'd mention it anyway. Just in case. > > > > Thijs > > > > > > #P window setfont "Sans Serif" 9.; > > #P number 164 70 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; > > #P window linecount 1; > > #P message 164 89 164 9109513 sad fglkjg werlwerkj asdfsdf $1 $1 > > $1; > > #P newex 164 110 26 9109513 print; > > #P window linecount 4; > > #P comment 209 29 100 9109513 drag the value while watching the max > > allocated memory in the taskmanager; > > #P connect 2 0 1 0; > > #P connect 3 0 2 0; > > #P window clipboard copycount 4; > > > >
    • Jan 09 2008 | 8:38 pm
      On Jan 9, 2008, at 11:36 AM, Thijs Koerselman wrote:
      > I assume print internally uses post() to print to the max window, > because it behaves identical to calling post() from my external. If > you keep dragging the value up and down the allocated memory keeps > increasing. Around 10kb per second.
      Hi Thijs,
      Keep in mind that the max window maintains a history of something like the last 20,000 lines. So if you use this example patcher, you should see that the memory will increase by a few MB, and then stabilize. Let us know if you don't see that behavior in your tests.
      -Joshua
    • Jan 09 2008 | 9:24 pm
      On Jan 9, 2008 8:38 PM, Joshua Kit Clayton wrote:
      > > Keep in mind that the max window maintains a history of something > like the last 20,000 lines. So if you use this example patcher, you > should see that the memory will increase by a few MB, and then > stabilize. Let us know if you don't see that behavior in your tests. >
      That makes absolute perfect sense. Thanks for clearing this up! Next time I'm looking for memory leaks I'll make sure I disable all window posts.
      Cheers, Thijs