PMEM Allocator for standard template library???

16 views
Skip to first unread message

Minseon Ahn

unread,
Jul 17, 2019, 5:56:30 AM7/17/19
to pmem
Hello, experts.

Is there any class or variable of pmem allocator for standard template library?

I would like to create a vector in DRAM, but store the contents of the vector in the pmem.
Since std::vector has a constructor with an allocator, I think there could be a pmem allocator.

std::vector<T,Allocator>::vector

explicit vector( const Allocator& alloc );

If there was a similar question previously, would you let me know a link to the answer?

Thanks in advance.

Best Regards,

Minseon Ahn


Igor Chorążewicz

unread,
Jul 17, 2019, 7:01:52 AM7/17/19
to Minseon Ahn, pmem
Hello,

The answer depends on whether you want to use PMEM as volatile memory pool or persistent storage. If it's the first case you can use pmem_allocator from memkind library (https://github.com/memkind/memkind).
If you want to make elements in your vector persistent then having vector in DRAM would be dangerous (possible persistent memory leak). In that case I would suggest using pmem::obj::vector ( http://pmem.io/2019/02/20/cpp-vector.html  ). This vector have the same interface as std::vector but stores data in PMEM and takes care of data consistency.

Igor

--
You received this message because you are subscribed to the Google Groups "pmem" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pmem+uns...@googlegroups.com.
To post to this group, send email to pm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pmem/363b1fe7-95e1-4db4-98e3-45c04343fee9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages