維尼的蜂巢

RealTime??!! It’s amazing!!!!

[Notes]MAX plugin 九月 2, 2005

Filed under: HeartStory — kevinlin @ 6:14 上午
   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.
   Cheers,
   – Casey

 

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s