Table of Contents

VBC09380: Out of memory

Severity: Error  ·  Family: VBC (static semantics / abstract syntax tree)  ·  Source metadata: VBCompileErrorInfo

A module declares more than 10,000 names at module level, or a fixed-size array of more than 16,777,216 elements.

The names are those of everything the module declares outside its procedures, all kinds together: variables, constants, Subs, Functions, properties (once each, whatever their accessors), Declare statements, enumerations and user-defined types. The members of an enumeration, the fields of a type and the locals of a procedure are not counted. The error is at the declaration of the 10,001st name.

MS-VBAL sets no limit. MS-VBA compiles a module of 10,800 such names, and not one of 11,000, whatever their kind and however long the names are, and reports "Out of memory" (recorded in Excel). RD-VBA's cap is 10,000, below that, so that a module RD-VBA compiles is one MS-VBA compiles; the message is MS-VBA's. The number of lines a module has is not limited: 60 procedures of 1,000 statements each compile in MS-VBA as in RD-VBA.

RD-VBA holds each element of an array in a cell of its own, and an array holds at most 16,777,216 (224) elements, in every dimension together. A fixed-size array declared with more - a variable of the module, a local, a Static local, a field of a user-defined type - is this error, at its last bound, whether its bounds are numbers or name constants; a dimension with no lower bound is counted from 1. MS-VBA (64-bit) compiles and allocates Dim b(100000000) As Byte (recorded in Excel): this is RD-VBA's own limit, and the message is MS-VBA's for memory it doesn't have. A ReDim of more elements is run-time error 7, Out of memory (RD-VBAL §5.4.3.3).

How it is raised

Situation Example Resolution
A module of generated declarations. 10,001 Private Const lines Move some of them to another module, or keep them in a table read at run time.
Many small procedures and module variables. 6,000 variables and 5,000 Subs Split the module by what its procedures are for.
A fixed-size array of more than 16,777,216 elements. Dim b(100000000) As Byte, Dim grid(1 To 4097, 1 To 4097) As Integer Work through the data in parts, or keep it in a file read a block at a time.

See also


ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca