1

I have a simulink model with a c++ SFunction I would like to send a large nested bus into, however the compiler crashes after about ten minutes with a lack of heap space error.

The bus has nine buses inside it and a further set of buses inside those, a total of 49 buses and 490 signals in a tree. I have generated the full bus definition and they are all in the global workspace. I have generated also the full structure definition in a header file, with each of the 49 buses using the header.

The automatically generated source for this SFunction is approximately 24000 lines.

Compiling this SFunction fails after a long time, complaining of insufficient heap space on pass 2. I am using the compiler shipped with Visual C++ 2010 Express.

I have experimented by filling the bus with elements one by one, and seen a nearly exponential growth in compile time to the point of failure. Why should the performance be so poor and is there a way to compile with a bus of this size?

J Collins
  • 2,106
  • 1
  • 23
  • 30
  • Have you tried using data dictionaries? This will remove the bus objects from the global workspace. I haven't tested if this has an impact on the compilation, but it might be worth a try and it's good to clean up your workspace anyway. – pmb Jul 09 '14 at 13:19
  • The context of the problem is passing out a large bus so an SFunction by analysing the buses and generating on-the-fly a header with all structures and placing all buses on the global workspace (only becuase they are needed for compilation.) The idea is being able to change the model and have the SFunction update itself automatically. Another limitation is working with MATLAB 2010b. Are data dictionaries compatible with this concept? – J Collins Jul 09 '14 at 13:22
  • They are compatible with the first part, but not with R2010b :( I think this feature was release around 2013. – pmb Jul 09 '14 at 13:24
  • What about the Optimization --> Signals and Parameters tab? Have you tried all the options there like "Reuse Block Outputs" and "Signal Storage Reuse"? – pmb Jul 09 '14 at 13:25
  • For other reasons we cannot use 'signal storage reuse', but all other optimisations are in use. – J Collins Jul 09 '14 at 13:32
  • Then I'm out of ideas. Every bus obj is a C struct, maybe the Coder just can't deal with such sizes. A total of 490 signals is not a lot though...and trying to reduce bus object or using arrays when possible? – pmb Jul 09 '14 at 13:54

0 Answers0