# ABAP Internal Table Memory Size Calculator

> Source: https://netray.co/tools/abap-internal-table-memory-size-calculator
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Estimate the memory an internal table needs, check it against a session limit and find the safe row count before you hit a short dump.

## Category

sap

## Erp

SAP ECC / S/4HANA

## Audience

- ABAP developer
- SAP Basis administrator
- SAP technical consultant

## Tool

**Kind:** calculator

**Inputs:**

#### Rows in the table

**Key:** rows

**Type:** number

**Default:** 1000000

**Min:** 1

**Step:** 50000

**Unit:** rows

#### Row width

**Key:** row_bytes

**Type:** number

**Default:** 220

**Min:** 1

**Step:** 10

**Unit:** bytes

**Help:** Sum of the component lengths. A character field of length 10 uses 20 bytes in a Unicode system.

#### Table type overhead factor

**Key:** overhead

**Type:** select

**Default:** 1.15

**Options:**

##### Standard table (about 1.15)

**Value:** 1.15

##### Sorted table (about 1.25)

**Value:** 1.25

##### Hashed table (about 1.4)

**Value:** 1.4

**Help:** A planning allowance for administration data and secondary keys, not an exact SAP figure.

#### Copies held at the same time

**Key:** copies

**Type:** number

**Default:** 2

**Min:** 1

**Step:** 1

**Unit:** copies

**Help:** For example the result table plus a sorted copy, or a table plus a loop work area snapshot.

#### Memory limit for the session

**Key:** limit_mb

**Type:** number

**Default:** 2048

**Min:** 64

**Step:** 128

**Unit:** MB

**Help:** Your effective extended plus heap allowance for a dialog or batch process, from your Basis team.

**Outputs:**

#### Raw data size

**Key:** raw_mb

**Expr:** rows * row_bytes / 1048576

**Format:** decimal

**Description:** Megabytes of payload.

#### Table size with overhead

**Key:** table_mb

**Expr:** raw_mb * overhead

**Format:** decimal

#### Total with copies

**Key:** total_mb

**Expr:** table_mb * copies

**Format:** decimal

**Primary:** true

#### Share of session limit

**Key:** pct_limit

**Expr:** total_mb / limit_mb * 100

**Format:** percent

**Primary:** true

#### Safe row count at 100 percent

**Key:** max_rows

**Expr:** floor(limit_mb * 1048576 / (row_bytes * overhead * copies))

**Format:** integer

#### Suggested package size at 25 percent

**Key:** pkg_rows

**Expr:** floor(0.25 * limit_mb * 1048576 / (row_bytes * overhead * copies))

**Format:** integer

**Description:** A conservative PACKAGE SIZE for chunked processing.

**Chart:**

#### Total memory in MB by row count

**Type:** line

**X:** rows

**From:** 100000

**To:** 10000000

**Steps:** 30

**Series:**

- total_mb

**Disclaimer:** An approximation for planning. Strings, nested tables and references are stored differently. Verify actual consumption with the ABAP memory inspector or the debugger memory view.

## Content

**Intro:** A report that works in test and dumps in production with an out-of-memory error is usually a row count problem. This calculator estimates how much memory an internal table takes and gives a safe package size for chunked reads.

**Sections:**

#### How to use it

**Body:** Work out the row width from the structure: add the lengths of all components, remembering that character fields take two bytes per character in Unicode systems. Enter the expected production row count, not the test count. Pick the table type, because hashed and sorted tables carry more administration data than a standard table. Set the number of copies you hold at once, since many programs keep both an input and a working copy. Compare the total with the memory limit given by your Basis team.

**Bullets:**

- Use production volumes, including year-end peaks
- Count every copy, including tables passed by value
- Ask Basis for the effective limit of the work process type

#### The formulas

**Body:** Raw size is rows times row width, divided by 1,048,576 to get megabytes. Table size multiplies that by an overhead factor for the table type. Total size multiplies by the number of copies. The safe row count divides the memory limit by the width, overhead and copies. The package size output takes a quarter of the limit, which leaves headroom for the rest of the program, other tables and the stack. The factors are planning allowances; real overhead depends on the release and the key setup.

**Bullets:**

- Size = rows x width x overhead x copies
- Use SELECT ... PACKAGE SIZE or a cursor to stay under the limit
- Keep headroom for everything else in the session

#### Fixing a memory problem

**Body:** When the estimate exceeds the limit, process data in packages: read a block, process it, write results and free the table before the next block. Select only the columns you need, since a narrower row cuts memory directly. Pass big tables by reference, not by value, and avoid building a second sorted copy if a sorted or hashed access path will do. The short dump TSV_TNEW_PAGE_ALLOC_FAILED in ST22 is the classic sign that an internal table outgrew the available memory.

**Bullets:**

- Use packages or cursors for large reads
- Select fewer columns
- Pass by reference and release tables with FREE or CLEAR
- Read the dump analysis in ST22 for the peak figure

**Cta:** Memory dumps in custom reports are a symptom of design, not just limits. Netray can review your biggest reports and suggest packaging and push-down changes.

**Faq:**

#### Why does a character field take twice the length in bytes?

**Answer:** Unicode systems store characters in two bytes. A field of type C with length 10 therefore uses 20 bytes in memory. Packed numbers, integers and dates use their own sizes, so add each component separately.

#### Is the overhead factor exact?

**Answer:** No. It is a planning allowance for administration data and secondary keys. Measure real consumption in the debugger or with the memory inspector when the result is close to the limit.

#### What is PACKAGE SIZE in a SELECT?

**Answer:** It makes the database return rows in blocks of a given size inside a SELECT loop, so you never hold the whole result at once. Process and clear each block before the next iteration.

#### Where do I find the memory limit?

**Answer:** It comes from profile parameters for extended memory and heap memory, and differs by work process type. Ask your Basis team for the effective values for dialog and for background jobs.

## Search terms

abap internal table memory size, tsv_tnew_page_alloc_failed, abap internal table size calculation, abap memory limit heap, abap select package size, abap out of memory internal table, abap standard sorted hashed table memory, abap memory consumption estimate

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
