unbound memory problem

74 views
Skip to first unread message

Amirouche Boubekki

unread,
Jul 26, 2016, 4:54:37 PM7/26/16
to Sophia database
Using sophy bindings and sophia 2.1 I try to load a several Gb file into a database but even after settings the memory limit the consumption grows without limit.

What I am doing wrong?

Here's more or less the code I use:

            from sophy import Sophia
           
from msgpack import loads, dumps

            env
= Sophia(db, auto_open=False)
            env
.memory_limit = 1024 * 1024 * 1024
            env
.open()

            posts
= env.create_database('Post', 'u32')

            filepath
= os.path.join('dump', 'Posts.xml')
           
for data in iterate(filepath):
                 posts
[int(data['Id'])] = dumps(data)
            env
.close()

Thanks!

Dmitry Simonenko

unread,
Jul 30, 2016, 8:16:47 AM7/30/16
to Sophia database
Hi,

It is possible to expect that memory usage will be memory_limit * 2 in some cases, due to malloc() behaviour (fragmentation).
Sophia implements memory limit only on logical level. Does the memory consumption stops at some point?

Thanks

Amirouche Boubekki

unread,
Jul 30, 2016, 4:53:39 PM7/30/16
to Sophia database


On Saturday, July 30, 2016 at 2:16:47 PM UTC+2, Dmitry Simonenko wrote:
Hi,

It is possible to expect that memory usage will be memory_limit * 2 in some cases, due to malloc() behaviour (fragmentation).
Sophia implements memory limit only on logical level. Does the memory consumption stops at some point?

no it doesn't. It goes well above 2Giga of RAM until there is no more memory left and it crash

Charles Leifer

unread,
Aug 15, 2016, 3:54:55 PM8/15/16
to Sophia database
From what I could tell when investigating your issue, the setting is working correctly.

If, after setting it and opening the env, I did "print env.memory_limit" and got back the value I set.

Dmitry Simonenko

unread,
Aug 15, 2016, 4:17:43 PM8/15/16
to Sophia database
Does "print env.memory_limit" equal to printing the value obtained from sp_getstring(env, "memory.limit", 0) ?

Charles Leifer

unread,
Aug 16, 2016, 4:31:04 PM8/16/16
to Sophia database
Actually it uses sp_getint(env, "memory.limit"). If you look at the source code for sophy you can see that accessing the memory limit revolves around this function:


When the memory limit property is defined on the Sophy class, it indicates that the value is an integer.

Amirouche Boubekki

unread,
Sep 21, 2016, 5:42:49 AM9/21/16
to Sophia database
The memory leak was in my code. I'm very sorry about the confusion.

Dmitry Simonenko

unread,
Sep 21, 2016, 5:50:18 AM9/21/16
to Sophia database
Ok, good that the problem has been resolved. Thanks for telling.
Reply all
Reply to author
Forward
0 new messages