Notifications
Clear all

[Closed] Bad allocation error in Max 9 w/ VC 2005

One of our programmers is having a strange problem with Max 9 (see below). Sparks tends to be so slow, I figured a cross-post here might help…

My company just migrated to VC 2005 and Max 9, so I set out to test our exporter and a scripted material plugin that I wrote, both of which work fine under Max 8 with VC 2003.

What I’ve found is that anytime my exporter code attempts to get at the paramdefs inside a ParamBlockDesc2 Max throws an exception that reads “bad allocation.”

Here’s a snippet of test code that throws the error:

 IParamBlock2 *pb2 = SDK_pMtl->GetParamBlock(2);
  ParamBlockDesc2 *pdc = pb2->GetDesc();
  unsigned short uCount = pdc->count;
  // uCount provides the correct number, in the case of the block at index 2, 51.
  
  for(int i=0; i< uCount; i++)
  {
    ParamDef pD = pdc->paramdefs[i];
    // if i > 0, Max throws the error
  }

Again, both the scripted material plugin and the exporter work fine under Max 8 and VC 2003.

Does anybody have any ideas? Was there a change I was supposed to have made when I migrated to Max 9 and/or VC 2005?

Thanks for any insights.

9 Replies

Hi Eric,

Many Max developers are facing memory problems when recompiling plugins for 3ds Max 9.
When having this kind of problem, the first thing to do is to ensure the project configuration : Hybrid/Release, libraries and headers used.

There’s an upgrade guide to 3ds Max 9 SDK (“Max 9 SDK Upgrade Guide”) but in your case I think it will not provide any help about ParamBlocks.

Sparks tends to be so slow

Yes, it seems that now if you are not an ADN Sparks member it will be difficult to get replies from Autodesk staff.

Hi,

I had a similar problem. As far as I can remember Initializing the pblock with NULL in the constructor of the plugin solved the problem;

pblock = NULL;

I don’t know if this helps exactly, but it seems that VS2005 is a bit more sensitive to wild pointers.

Best regards,
Dieter

3 Replies
(@lechoo)
Joined: 11 months ago

Posts: 0

Deffinetly worth trying, in my case it helped.

(@shmigget)
Joined: 11 months ago

Posts: 0

Hi, I’m the developer in question (thanks for posting about this, posm). Please correct me if I’m wrong, but aren’t you guys talking about a C++ material plugin, not a scripted material plugin?

(@shmigget)
Joined: 11 months ago

Posts: 0

Hi, I’m the developer in question (thanks for posting about this, posm). Please correct me if I’m wrong, but aren’t you talking about a C++ material plugin, not a scripted material plugin?

Hi,

I was talking about a c++ plugin. Perhaps I understood the question wrong, because your example code was c++ and you mentioned that you have problems migrating from vs2003 to vs2005. Is your plugin written with script?

Dieter

1 Reply
(@shmigget)
Joined: 11 months ago

Posts: 0

My apologies for any confusion. The material plugin is written in maxscript. The exporter is written in C++. I get the error when the exporter tries to read from the param blocks that are created in the scripted material plugin.

A coworker of mine found some answers. As I’d found earlier, accessing any of the paramdefs whose index is greater than zero from the paramdefs array now returns junk or results in the “bad allocation” error, but getting at them via ParamDef& pD = pb2->GetParamDef() works.

Hm,

strange enough. Thanks for sharing.

Best regards,

Dieter