How to resolve mmap memory and realm.close() issue


#1

I am currently using and exporting realm as this

export default new Realm(
    {
        schema: [APPSCHEMA, POSTSCHEMA, CATEGORYSCHEMA, FAVOURITESCHEMA],
        deleteRealmIfMigrationNeeded: true
    }
)

but i run into mmap(): memory error

after i added realm.close() at the end of each ream,write

realm.write(() => {
            realm.create('Post', {
                id: uuidv4(),
                title: item.title.rendered ? item.title.rendered : '',
                featured: (Object.keys(item.better_featured_image.media_details).length !== 0)
                            ? item.better_featured_image.media_details.sizes.medium.source_url
                            : undefined ,
                excerpt: item.excerpt.rendered ? item.excerpt.rendered : '',
                text: item.content.rendered ? item.content.rendered : '',
                uri: item.link ? item.link : undefined,
                category: cat
            })
        })
        
        realm.close()

but then i got error, cannnot access realm that has been close.

Please help, where do i place the realm.close() to avoid mmap error