Skip to main content

memory_free

1. MEMORY_FREE Function

The MEMORY_FREE function in H2 database is used to retrieve the amount of free memory available in the database.

2. Syntax

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

MEMORY_FREE()

Arguments

  • The MEMORY_FREE function does not accept any arguments.

Return

  • The MEMORY_FREE function returns the amount of free memory available in the database in bytes.

3. Notes

  • The MEMORY_FREE function in H2 database provides information about the free memory available within the database, which may not necessarily reflect the overall system memory.
  • The returned value represents the amount of free memory in bytes. To convert it to a more readable format, you can use appropriate conversion functions or calculations.
  • It is important to note that the MEMORY_FREE function is specific to the H2 database and may not be available in other database systems.

4. Examples

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

Example 1 - Retrieving the amount of free memory in bytes:

SELECT MEMORY_FREE() AS free_memory;

Output:

free_memory
-----------
1234567890

Example 2 - Converting the free memory to megabytes:

SELECT ROUND(MEMORY_FREE() / POWER(1024, 2), 2) AS free_memory_mb;

Output:

free_memory_mb
--------------
1175.99

There are no directly related functions to the MEMORY_FREE function in H2 database. However, you may find the following functions useful:

  • DATABASE() - Retrieve the name of the current database.
  • SESSION_ID() - Retrieve the ID of the current session.
  • CURRENT_TIMESTAMP() - Retrieve the current timestamp.