Skip to content

Memory usage keeps increasing

I found that memory usage keeps increasing if I called add method. It should not be as you expected, so please take a look and fix it if you can.

import numpy as np
from tqdm import tqdm
from cpprb import ReplayBuffer

BUFFER_SIZE = int(1e6)
NP_DTYPE = np.float32

buffer_kwargs = {
    'size': 1000000,
    'default_dtype': NP_DTYPE,
    'env_dict': {
        'obs': {'shape': (64, 64, 1)},
        'next_obs': {'shape': (64, 64, 1)},
        'act': {'shape': (3,)},
        'rew': {},
        'done': {}
    }
}

replay_buffer = ReplayBuffer(**buffer_kwargs)

dummy_obs = np.zeros(shape=(64, 64, 1), dtype=NP_DTYPE)
dummy_act = np.zeros(shape=(3,), dtype=NP_DTYPE)
dummy_rew = 0.
dummy_done = False

for _ in tqdm(range(BUFFER_SIZE)):
    replay_buffer.add(obs=dummy_obs, next_obs=dummy_obs, act=dummy_act, rew=dummy_rew, done=dummy_done)