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 8568033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:01:00+00:00 2026-06-11T18:01:00+00:00

I am using db4o 8.0. The db4odatabase file size is 21MB. The database has

  • 0

I am using db4o 8.0.
The db4odatabase file size is 21MB.
The database has following Objects in it.

User : There is 1 user in db.
PostedMessage : There are 10000 postedMessages in db.

I delete all 10000 PostedMessages. Then I try to defragment the db4o database. Following code is used for Defragmentation.

private void processDefrag() {
    try {
        String dbpath = "D:\\db4oDatabase";

        IdMapping mapping = new InMemoryIdMapping();
        //new DatabaseIdMapping(dbpath); //use this if heap overflows

        DefragmentConfig config = new DefragmentConfig(dbpath, dbpath+".bak", mapping);
        config.storedClassFilter(new AvailableClassFilter());
        config.forceBackupDelete(false);
        config.objectCommitFrequency(1000);
        Defragment.defrag(config);
        System.out.println("Defrag completed");

    } catch (IOException ex) {
        ex.printStackTrace();
    }
}

My expectation is that the db4oDatabase file size will go back to 21 Kb. And the db4oDatabase will still contain the 1 User object in it. However, after running the above code, the db4odatabase becomes completely empty. Why is it happening like that?

How can I avoid losing the other objects which were not deleted (in this case the 1 User object)? What is the right way of doing defragmentation on db4o 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-11T18:01:01+00:00Added an answer on June 11, 2026 at 6:01 pm

    If it’s not accepting the class because it can’t find it, you might try writing a StoredClassFilter of your own that just accepts all StoredClass objects.

    public class AcceptAllClassFilter implements StoredClassFilter {
    
        @Override
        public boolean accept(StoredClass storedClass) {
            return true;
        }
    }
    

    Then:

    config.storedClassFilter(new AcceptAllClassFilter());
    

    This will work unless the defrag process just deletes everything without a StoredClass automatically. If this is the case, we may need to figure out why the User class doesn’t have a corresponding StoredClass instance for the container.

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

Sidebar

Related Questions

I am writing an application using an object database ( db4o ) and in
I am using db4o 8.0. I have a class PostedMessage{ @Indexed long receivedTime; @Indexed
I'd like to store objects of an anonymous type to a db4o database. For
i'm using db4o with objects: public Tra(String x, int y, int z, int pos,
I have a User object which has a collection of Transaction objects under it.
I am using DB4O to store my objects. Please find below code to retrieve
I am using db4o as DBMS and I have a question: Is there any
I currently have an application, where it's primary performance issue is using file-based database
I'm working with a db4o database that was created in Java, but I'm using
Does anyone already used db4o OO database manager in a mobile project using Xamarin

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.