# Extending Database Memory in C#

> A C# application can extend the amount of memory for use by a database by calling the Database method `Extend()`.

> The following code snippet demonstrates the recommended way for C# applications to extend a database:

>         void extend_db_memory(Database db)
>         {
>             int size = 1024 * 1024;
>             Database.Device[] dev = new Database.Device[1];

>             devs[0] = new Database.PrivateMemoryDevice(Database.Device.Kind.Data, size);
>             db.Extend(dev);

>         }

> There is also a version of the `Extend()` method that allows passing a connection context. For example, the above function could be rewritten as follows:

>         void extend_db_memory(Database db, byte[] ctx)
>         {
>             int size = 1024 * 1024;
>             Database.Device[] dev = new Database.Device[1];

>             devs[0] = new Database.PrivateMemoryDevice(Database.Device.Kind.Data, size);
>             db.Extend(dev, ctx);

>         }