[Notes]MAX plugin

   In general, we don’t allocate any memory that MAX frees, or vice
   versa.  However, there is ONE PLACE where we do, which is the application
   extra data buffer which gets passed to MAX and stored in the MAX
   file.  This MUST be allocated with the same memory allocator that
   MAX uses, otherwise you will get intermittent crashes and other
   natural disasters that will be very hard for you to find.  So, please
   be aware of this.  Search this file for “malloc".  You will find it
   in one place.  That is the place where the aforementioned sensitive
   allocation occurs.  You must make sure that this malloc is going to
   end up going to the same place as MAX’s malloc would go.
   And if you thought that was bad, well you should also be aware that
   anywhere you use a MAXScript definition macro (like def_visible_primitive),
   it inlines the call to delete.  So you may not THINK you need to
   watch the memory situation in those files, but you do, because even
   though you’re not calling an unbalanced malloc/free/new/delete/etc.
   that Discreet’s code will pick up, MAX is helpfully inserting one
   in there for you.  Pretty sweet huh?
   In MAX 6 and up, there is a header file called MAX_Mem.h, which will
   define malloc to point to their exported core malloc function.  So,
   in general, for MAX >= 6, you should generally be covered.  However,
   for MAX < 6, you MUST build with VC 6 with the /MD switch, or have
   some other cunning plan that will achieve the same effect.  OR AT LEAST
   THAT’S WHAT YOU’D THINK.  But it actually turns out that in this MAX_Mem.h,
   they switch on whether or not the compiler is VC 7 or up, so if you’re
   compiling with VC 6, you get no redirection whatsoever.  So it’s like
   including nothing at all.  THEREFORE, I have made my own redirector
   which is part of the max_proxy.h include, which should cover things.
   That’s all I have to say on this subject.  This notice is mirrored
   in max_tool_interface.cpp and _max_scripting.cpp for
   your pleasure.
   – Casey




WordPress.com 標誌

您的留言將使用 WordPress.com 帳號。 登出 /  變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 /  變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 /  變更 )


您的留言將使用 Facebook 帳號。 登出 /  變更 )


連結到 %s