dmlc/ps-lite

Slow memory leak?

Closed this issue · 2 comments

Is it possible there's a slow memory leak in ps-lite? If I run the following simple example, the memory usage of the worker rises indefinitely at a rate of approximately 2MB / sec.

I've traced the origin of the leaked memory to van.cc's Recv(), but am unsure of who should be responsible for freeing it. Any advice or suggestions?

#include "ps.h"

#include "ps.h"
typedef float Val;

int CreateServerNode(int argc, char *argv[]) {
  ps::OnlineServer<Val> server;
  return 0;
}

int WorkerNodeMain(int argc, char *argv[]) {
  using namespace ps;
  std::vector<Key> key = {1};
  std::vector<Val> recv_val;
  KVWorker<Val> wk;
  while (1) {
    wk.Wait(wk.Pull(key, &recv_val));
  } 
  return 0;
}
mli commented

i probably didn't delete the meta data well, since it's tiny comparing to the key-value pairs. will have a look later.

I think I found it!

In base/parallel_ordered_match.h, line 98 now reads:

  SArray<V>* val = new SArray<V>(dst_val->data(), dst_val->size(), EmptyDel<V>());
  return ParallelOrderedMatch(src_key, src_val, dst_key, val, k, op, num_threads);

I think that the val is a temporary wrapper and needs to be freed, so the following seems to work:

  SArray<V> val(dst_val->data(), dst_val->size(), EmptyDel<V>());
  return ParallelOrderedMatch(src_key, src_val, dst_key, &val, k, op, num_threads);

Does this look correct to you? I just issued a PR for it.