Skip to main content


1. MEMORY_USED Function

The MEMORY_USED function in H2 database is used to retrieve the amount of memory currently used by the database.

2. Syntax

The syntax for the MEMORY_USED function in H2 database is as follows:



  • None. The MEMORY_USED function does not require any arguments.


  • The MEMORY_USED function returns the amount of memory used by the database in bytes.

3. Notes

  • The MEMORY_USED function provides information about the memory usage of the H2 database at the moment the function is called.
  • The value returned by the MEMORY_USED function represents the memory usage in bytes.
  • This function can be useful for monitoring and optimizing memory consumption in the H2 database.

4. Examples

Here are a few examples demonstrating the usage of the MEMORY_USED function in H2 database:

Example 1 - Retrieving the current memory usage:

SELECT MEMORY_USED() AS memory_used;



Example 2 - Using the MEMORY_USED function in a query:

SELECT id, name
FROM users
WHERE MEMORY_USED() < 10000000;


id | name
1 | John
2 | Alice
3 | Bob
  • memory_free - Calculate the amount of free memory available in the database.