1 Reply Latest reply: Jan 3, 2011 8:30 PM by Chris Cox RSS

    a question about memory management

    marcoolivotto Community Member

      hi all,

      i am writing a filter plugin using cs5 sdk on a mac (with XCode 3.1.4).

      at some point, i need to allocate memory inside the program, and i do that via malloc(), followed by a free() inside the DoFilter() function.

      all this works perfectly under osx leopard, but when i try to run it under snow leopard, it crashes like this:

       

      Exception Type:  EXC_CRASH (SIGABRT)
      Exception Codes: 0x0000000000000000, 0x0000000000000000
      Crashed Thread:  0  Dispatch queue: com.apple.main-thread
      
      Application Specific Information:
      abort() called
      
      Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
      0   libSystem.B.dylib                  0x00007fff81c78616 __kill + 10
      1   libSystem.B.dylib                  0x00007fff81d18cca abort + 83
      2   libSystem.B.dylib                  0x00007fff81c306f5 free + 128
      3   Dissolve                           0x0000000123abd75a DoFilter() + 3593
      4   Dissolve                           0x0000000123abd98e DoStart() + 254
      5   Dissolve                           0x0000000123abeacb PluginMain + 2502
      

       

      it is quite obvious that this is not a plug-in problem proper, but rather an os problem. as soon as i comment out the free() functions, the plug-in works as expected - but this is, of course, a nasty practice.

      i thought this might be due to some kind of incompatibility between the system libraries of snow leopard and leopard, so i re-compiled the plug-in under snow leopard with no hassle, but the result is the same. in other words, snow leopard doesn't like me to free() memory at all. :-)

      does anyone has an idea about the reason for this behaviour?

      bypassing malloc() completely by defining buffers in the Data struct of the plug-in would be an idea, but for what i need to do this would be a simpler method.

      any suggestion is really welcome!

       

      all the best and thanks in advance for your replies,

       

      marco olivotto

        • 1. Re: a question about memory management
          Chris Cox Adobe Employee

          Looks like you freed some memory twice, or that wasn't allocated.  Most likely there are messages in the system console log about this.

          MacOS 10.6 added some additional error checking in the memory allocation systems, and more still in 64 bit.

           

          Also, if you are allocating large blocks of memory, you should not use the OS allocator, but allocate through Photoshop so the host app can free memory as needed and account for your plugins memory usage (so you don't run out of address space or RAM so easily).