Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8089501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:24:52+00:00 2026-06-05T19:24:52+00:00

If a create a in-memory sqlite database using syntax below, then what is the

  • 0

If a create a in-memory sqlite database using syntax below, then what is the size of maximum memory allocated to it?

my $dbh = DBI->connect('dbi:SQLite:dbname=:memory:');

What will happen if size of in-memory database becomes greater than max available memory.

Suppose I have 1 GB free and the database size become 1.1 GB, then will some data be written to disk or what?

Is there a way to change the value of max-memory allocated to a in-memory sqlite database?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:24:54+00:00Added an answer on June 5, 2026 at 7:24 pm

    It will use virtual memory, yes it will write out to the disk once you’ve exceeded all your freely available memory, when that’s exceeded, it may throw an exception, have an undefined behavior, or it may be OS dependent.
    These are SQLite limits: http://www.sqlite.org/limits.html.

    If you want to set a maximum database size you can execute the following SQL command:

    PRAGMA page_size = 512
    PRAGMA max_page_count = 195313
    

    In Perl:

    $dbh = DBI->connect('dbi:SQLite:dbname=:memory:');
    $query_handle = $dbh->prepare("PRAGMA page_size = 512");
    $query_handle->execute();
    $query_handle = $dbh->prepare("PRAGMA max_page_count = 195313");
    $query_handle->execute();
    

    You can test it by creating a temporary table and using a loop to insert a large number of objects, until it hits the limit.

    This will set your max database size to 100,000,256 bytes.

    SQlite database are stored in pages, this will set the page size and the max number of pages for your database. you can play with either parameter to suit your needs; bigger pages means more performance, but faster growth.

    These are all the PRAGMAS that sqlite supports: http://www.sqlite.org/pragma.html#pragma_page_size.

    This is a simple test in Python:

    import sqlite3
    
    con = sqlite3.connect(':memory:')
    cur = con.cursor() 
    cur.execute("PRAGMA max_page_count = 195313")
    cur.execute("PRAGMA page_size = 512")
    cur.execute("CREATE TABLE test (random_values TEXT)")
    index = 0
    query = "INSERT INTO test (random_values) VALUES ('%s')" % "".join(['a' for index in xrange(1000)])
    while True:
        try:
            c = cur.execute(query)
            index += 1
        except Exception as ex:
            print str(ex)  
            break       
    
    print index * 1000
    

    Fairly quickly you’ll get something like this:

    sqlite3.OperationalError: database or disk is full

    I get 93915000 bytes due to the overhead, so play with the settings if you want exactly 100 megabytes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible somehow to create in-memory database in SQLite and then destroy it
Here's my problem, I have one sqlite memory database by using QSql . I
My application creates a in-memory database (:memory:) using sqlite as a back end. I
When I create a SQLite memory database - how do I delete it when
I am using Python to create an in-memory sqlite3 database with a timestamp column.
sqlite is able to create in-memory database, but is it possible done in iPhone?
I am trying to create an offline registry in memory using the offreg.dll provided
I have a :memory: database. I want to create 5 tables in that database.
I'm using an sqlite database in my app. I have this dbhelper class in
I am thinking of using SQLite as an in memory stub for my Oracle

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.