Is there any limit to the size of objects I can define?

Obviously the amount of memory implemented by the device is the ultimate limit, but due to the way things are necessarily linked into memory and fragmentation of memory, there may be additional restrictions in the size of objects. It may be possible you receive memory errors even with some memory remaining.

Limitations with the 8-bit devices are:

  • There is no actual function size limit for MPLAB® XC8 Compilers. But for the PIC10/12/16 devices (Baseline and mid-range parts) functions that do cross pages may be slightly less efficient due to longer call and goto code sequences that must be employed. This is not the case for PIC18 and enhanced mid-range devices.
  • In terms of data objects, all objects must be able to fit into the general purpose memory in one data bank. (With mid-range and baseline devices, some of each data bank is taken up by special function registers.) Again, the exception is for PIC18 and enhanced mid-range PIC® devices which can define objects larger than one bank in size.

The linker never deals with placement of variables; it only deals with placement of blocks of variables. Like everything else, variables are placed into a psect (section) which is linked as a whole. A psect cannot be split, which can mean that it may not be able to be located when there are only small gaps remaining in memory.

Also see the FAQ "Can’t find space error".

© 2016 Microchip Technology, Inc.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.