[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

High memory usage when using svn_fs_make_file()

From: Lars Jessen <LJessen_at_mikrov.dk>
Date: Mon, 21 Jan 2008 13:03:56 +0100


I'm trying to use the the svn_fs module to build a database of 10000
files, but it seems that every call to svn_fs_make_file() eats about
300+kb of memory. The
following code illustrates the problem:

#include <apr_lib.h>
#include <svn_cmdline.h>
#include <svn_fs.h>
#include <svn_pools.h>
#include <iostream>
#include <strstream>

void CheckError(svn_error_t* error){
    if(error == NULL)
    std::cerr << "Error: " << error->message << std::endl;

int main(){
    const char* repositoryPath = "d:/svntest";

    svn_cmdline_init("svntest", stderr);

    apr_allocator_t *allocator;

    apr_pool_t *pool = svn_pool_create_ex(NULL, allocator);
    apr_allocator_owner_set(allocator, pool);
    if(NULL == pool){
        std::cerr << "Error initializing pool" << std::endl;
        return -1;

    svn_error_t* error;

    error = svn_fs_initialize(pool);

    svn_fs_t* fs;

    error = svn_fs_open(&fs, repositoryPath, NULL, pool);
        apr_hash_t* hash = apr_hash_make(pool);
        apr_hash_set(hash, SVN_FS_CONFIG_FS_TYPE, APR_HASH_KEY_STRING,

        error = svn_fs_create(&fs, repositoryPath, NULL, pool);

    // Get revision
    svn_revnum_t youngest_rev;
    error = svn_fs_youngest_rev(&youngest_rev, fs, pool);

    svn_fs_txn_t *txn;

    apr_pool_t *txpool = svn_pool_create_ex(pool, allocator);

    error = svn_fs_begin_txn(&txn, fs, youngest_rev, txpool);

    svn_fs_root_t* root;
    error = svn_fs_txn_root(&root, txn, txpool);

    std::cout << "creating files" << std::endl;

    for(int i=0;i<1000;i++){
        std::strstream s;
        s << "file" << i << ".txt";
        error = svn_fs_make_file(root, s.str(), txpool);

    std::cout << "commit'ing" << std::endl;

    const char* conflict;
    error = svn_fs_commit_txn(&conflict, &youngest_rev, txn, txpool);

    std::cout << "ok" << std::endl;


    return 0;

The above code takes a long time to complete and memory usage peeks at
about 600MB.
What am I doing wrong?
I'm using svn-win32-1.4.6

- Lars

To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: users-help_at_subversion.tigris.org
Received on 2008-01-21 13:55:03 CET

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.