<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Issues debugging 3dsmax 2016 due to object memory layout in 3ds Max Programming Forum</title>
    <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/issues-debugging-3dsmax-2016-due-to-object-memory-layout/m-p/6304394#M14616</link>
    <description>&lt;P&gt;Thank you for this reply,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;was not aware of the Hyrid configuration as I am returning to a project that was originally designed for Max2011 and at the time the original developer had already been working in a debug configuration where the sdk&amp;nbsp;would allocate and deallocate in its way but since the header didnt change VS was able to work around it. Since here we had the header change while, of course, the compiled application uses release libraries, a conflict in reading occured by exactly the size of that one additional pointer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my last question in the original comment was whether this was left intentionally because it seemed that this was the only _debug check in the sdk and going back to the older project we had, I saw 0 occurences of _debug in the included headers and just made the assumption that there were specifically compiled headers that did not have these checks. Now i see that this was as designed because of the existance of the hybrid option.&lt;/P&gt;</description>
    <pubDate>Mon, 02 May 2016 19:19:26 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-05-02T19:19:26Z</dc:date>
    <item>
      <title>Issues debugging 3dsmax 2016 due to object memory layout</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/issues-debugging-3dsmax-2016-due-to-object-memory-layout/m-p/6283161#M14613</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was running some tests on my plugins with VS2013 and compiled by code with debug flags and started encountering an error that I could not reproduce on a release version of my libraries. At one point in my code I called IParamBlock2 -&amp;gt; getValue(PBBitmap) and would try to load it and do various operations on the bitmap. In my release it worked fine, the bitmap would load, i could use it as expected. In debug I would crash with some improperly instantiated bitmap, this issue did not occur in previous iterations of our plugins (max08/max11).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Soon it was realized that when getting the values in a debug configuration the bm member of the&amp;nbsp;PBBitmap would not come instantiated as NULL instead would be a pointer with a no mans land address (0xabababab). After various amounts of poking around&amp;nbsp;we decided to check on the sizeof the classes in both debug and release and got the following:&lt;/P&gt;&lt;PRE&gt;debug &amp;nbsp;| PBBitmap:704 BitmapInfo:696 Bitmap:96
release&amp;nbsp;| PBBitmap:696 BitmapInfo:688 Bitmap:96&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;So we dug a bit further into BitmapInfo and found this in the&amp;nbsp;MaxSDK::Util::Path which is a member of the class&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;class PathImpl;
const AutoPtr&amp;lt;PathImpl&amp;gt; mImpl;
#if defined(_DEBUG)
//! Useful for inspecting the path in the debugger
const MCHAR* mdata;
#endif&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So it seems that when we compile under debug, VS assumes that we have this mdata and starts pulling all sorts of strange quirks with the code while our included libraries are&amp;nbsp;only release compiled.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Assuming we can't get the debug libraries for max, is there some sort of workaround for this issue?&lt;BR /&gt;&lt;BR /&gt;I can delete the #if code from my local header files but i wonder why this code was left here anyways&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 22:27:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/issues-debugging-3dsmax-2016-due-to-object-memory-layout/m-p/6283161#M14613</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-04-20T22:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Issues debugging 3dsmax 2016 due to object memory layout</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/issues-debugging-3dsmax-2016-due-to-object-memory-layout/m-p/6304341#M14615</link>
      <description>&lt;DIV&gt;
&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general, when developing C++ plugins for applications like 3ds Max, a developer should not forget about things like &lt;A href="https://en.wikipedia.org/wiki/Application_binary_interface" target="_blank"&gt;ABI&lt;/A&gt;.&lt;BR /&gt;You must keep in mind that a plugin developer is compiling his plugin against an application compiled in release build &lt;EM&gt;(in our case 3ds Max)&lt;/EM&gt;, and since the allocation/dealocation procedure is different in case of release and debug procedure - it is understandable that if you compile your plugin in debug mode, it will result in crashes when the memory allocated in "release way" is dealocated in "debug way" or vice-verso.&lt;/P&gt;
&lt;P&gt;To solve this problem, there is a special &lt;A href="http://help.autodesk.com/view/3DSMAX/2017/ENU/?guid=__files_GUID_AF966D24_7646_4EE2_AC0D_DEA05DA277B9_htm" target="_blank"&gt;Hybrid configuration&lt;/A&gt;, which in essence is a mix of release and debug configuration and whose main idea is to ensure the same memory allocation/dealocation procedure is used by your plugin and 3ds Max.&lt;/P&gt;
&lt;P&gt;Thus, the recommended way of debugging your plugins is to use the Hybrid configuration along with debug symbols as described &lt;A href="http://help.autodesk.com/view/3DSMAX/2017/ENU/?guid=__files_GUID_77CCF2FD_0CD7_45C1_B4BC_877E3A28A5D5_htm" target="_blank"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Regarding the existance of &lt;STRONG&gt;_DEBUG&lt;/STRONG&gt; within the SDK, this is because the very same SDK is used internally by 3ds Max itself, which could be seen as &lt;A href="https://en.wikipedia.org/wiki/Eating_your_own_dog_food" target="_blank"&gt;"dogfooding"&lt;/A&gt;.&lt;/P&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 18:57:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/issues-debugging-3dsmax-2016-due-to-object-memory-layout/m-p/6304341#M14615</guid>
      <dc:creator>denis_grigor</dc:creator>
      <dc:date>2016-05-02T18:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: Issues debugging 3dsmax 2016 due to object memory layout</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/issues-debugging-3dsmax-2016-due-to-object-memory-layout/m-p/6304394#M14616</link>
      <description>&lt;P&gt;Thank you for this reply,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;was not aware of the Hyrid configuration as I am returning to a project that was originally designed for Max2011 and at the time the original developer had already been working in a debug configuration where the sdk&amp;nbsp;would allocate and deallocate in its way but since the header didnt change VS was able to work around it. Since here we had the header change while, of course, the compiled application uses release libraries, a conflict in reading occured by exactly the size of that one additional pointer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my last question in the original comment was whether this was left intentionally because it seemed that this was the only _debug check in the sdk and going back to the older project we had, I saw 0 occurences of _debug in the included headers and just made the assumption that there were specifically compiled headers that did not have these checks. Now i see that this was as designed because of the existance of the hybrid option.&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 19:19:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/issues-debugging-3dsmax-2016-due-to-object-memory-layout/m-p/6304394#M14616</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-05-02T19:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: Issues debugging 3dsmax 2016 due to object memory layout</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/issues-debugging-3dsmax-2016-due-to-object-memory-layout/m-p/8618534#M14617</link>
      <description>&lt;P&gt;I request that the use of defined(_DEBUG) in class Path be treated as a bug and logged.&amp;nbsp; This clause appears in only two places in the SDK, thus it is not very "standard" and creates a tricky pitfall.&amp;nbsp; The solution could be a different define, like defined(MAX_DEBUG).&amp;nbsp; Long term, a potentially better solution is to always define Path::mdata even in release builds, but only populate this value in debug builds (would require an SDK break through).&lt;/P&gt;
&lt;P&gt;Otherwise, every plug-in developer must avoid compiling in debug configuration, instead using "release-without-optimization" (hybrid).&amp;nbsp; It's standard practice for plugin developers to compile in debug, regardless of whether 3ds Max is a release configuration app.&amp;nbsp; To understand that, remember that developers are working with many different apps (including non-Autodesk apps like Blender), not just 3ds Max, and in a complex build environment.&amp;nbsp; Imagine if all 3dsmax projects needed to be changed because of one pitfall in one third-party dependency, it would be costly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another solution for third-party developers is to change the header to remove the defined(_DEBUG) clause.&amp;nbsp; But that would need to be done every time setting up a new machine or reinstalling the SDK, not really a better solution.&lt;BR /&gt;&lt;BR /&gt;Also, developers need to see the value of Path objects while debugging.&amp;nbsp; Right now that's very tedious because mImpl is private.&amp;nbsp; Is there a standard way to see the Path value in a debug watch window, other than changing the source code and adding to call GetCStr()?&lt;BR /&gt;&lt;BR /&gt;Thank you for the help,&lt;/P&gt;
&lt;P&gt;Michaelson Britt&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 10:07:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/issues-debugging-3dsmax-2016-due-to-object-memory-layout/m-p/8618534#M14617</guid>
      <dc:creator>michaelsonbritt</dc:creator>
      <dc:date>2019-02-25T10:07:51Z</dc:date>
    </item>
    <item>
      <title>Re: Issues debugging 3dsmax 2016 due to object memory layout</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/issues-debugging-3dsmax-2016-due-to-object-memory-layout/m-p/8623422#M14618</link>
      <description>&lt;P&gt;Update, there is a way to inspect MaxSDK::Util::Path objects in the Visual Studio watch window.&amp;nbsp; Use the following, replacing myPath with the path object,&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;CODE&gt;&lt;FONT color="#000000"&gt;(wchar_t*)(8+(uint64_t)(&lt;EM&gt;myPath&lt;/EM&gt;.mImpl.mPtr))&lt;/FONT&gt;&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;More detail is &lt;A href="https://area.autodesk.com/tutorials/debugging-path-objects-in-a-visual-studio-watch-window/" target="_blank"&gt;here.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Michaelson Britt&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 00:41:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/issues-debugging-3dsmax-2016-due-to-object-memory-layout/m-p/8623422#M14618</guid>
      <dc:creator>michaelsonbritt</dc:creator>
      <dc:date>2019-02-27T00:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: Issues debugging 3dsmax 2016 due to object memory layout</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/issues-debugging-3dsmax-2016-due-to-object-memory-layout/m-p/8625063#M14619</link>
      <description>&lt;P&gt;I can understand if they decide to not remove the _DEBUG define in their headers, as plugin developers we are expected to work within their API specifications.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the debugging of Path objects should be written in the headers as a comment instead of requiring lost time to researching.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;as for your comment "&lt;SPAN&gt;Another solution for third-party developers is to change the header to remove the defined(_DEBUG) clause.&amp;nbsp; But that would need to be done every time setting up a new machine or reinstalling the SDK, not really a better solution." Well this is what I did for my team at my company, and created a quick batch script that does this and is explicitly mentioned in documentation that this should be run with sdk installation. it was the easiest approach for our existing debug configuration. The hybrid configuration actually took much more work to get running than expected because of the simultaneous need to include my engine header/sources and the 3dsmax headers.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;sidenote: Also I am the same user that originally posted this issue, just using a different account due to company license&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 15:44:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/issues-debugging-3dsmax-2016-due-to-object-memory-layout/m-p/8625063#M14619</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-27T15:44:38Z</dc:date>
    </item>
  </channel>
</rss>

