'expo.sqlite high memory usage when creating to many transactions at a close interval

I am using expo-sqlite for my application and encounter an odd problem.

I have a ``ScrollViewand I want to save the scroll position too the db and so I am doing it inonScrollEndDrag`

The issue is that as time gets by say 3 to 4 hours, I see a memory increase in the app Info.

it goes to 1GB+ sometimes. Is that normal?

I am using expo-sqlite-wrapper Which I do not believe that the issue originate from there.

You can look at its code here as I am the author of the library, I could make change and fix it if there is an issue.

Here is the code for save operation, it really as simple as savechange() and Save() operation in the link above.

            onScrollBeginDrag={() => {
                clearTimeout(onScrollTimeout.current);
                scrollable.current = true;
            }}
            onScrollEndDrag={({ nativeEvent }) => {
                clearTimeout(onScrollTimeout.current);
                onScrollTimeout.current = setTimeout(() => {
                    scrollable.current = false;
                    if (nContext.state.currentChapterSettings && nContext.state.currentChapterSettings.savechanges && !nContext.state.viewPlayer)
                        nContext.state.currentChapterSettings.savechanges();
                }, 1500);
                if (!nContext.state.viewPlayer)
                    setContentOffset(nativeEvent.contentOffset);
            }}
            onScroll={({ nativeEvent }) => {
                if (!nContext.state.viewPlayer && scrollable.current) {
                    onScroll(nativeEvent);
                }
            }}

Is it maybe accessing the database to often is wrong or is it really alright as the sqlite takes care of the memory issue when its full?

Could anyone please explained how SQLite really handle the memory, as I may not understanding this right and this behavior is really alright.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source