[
https://issues.apache.org/jira/browse/CASSANDRA-2521?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13050637#comment-13050637
]
Jonathan Ellis commented on CASSANDRA-2521:
-------------------------------------------
bq. We could use this trick
It's not obvious that this works with mapped buffers (as opposed to "normal"
malloc'd direct buffers) but it looks like it does:
DirectByteBuffer constructor, used via reflection to create MappedByteBuffer
objects (!)
{code}
// For memory-mapped buffers -- invoked by FileChannelImpl via reflection
protected DirectByteBuffer(int cap, long addr, Runnable unmapper) {
super(-1, 0, cap, cap, true);
address = addr;
viewedBuffer = null;
cleaner = Cleaner.create(this, unmapper);
}
{code}
Here's the unmapper that gets passed, from FCI:
{code}
private static class Unmapper
implements Runnable
{
private long address;
private long size;
private Unmapper(long address, long size) {
assert (address != 0);
this.address = address;
this.size = size;
}
public void run() {
if (address == 0)
return;
unmap0(address, size);
address = 0;
}
}
{code}
(And of course Cleaner.clean just calls run on its Runnable, with a second
layer of only-run-this-once wrapping.)
> Move away from Phantom References for Compaction/Memtable
> ---------------------------------------------------------
>
> Key: CASSANDRA-2521
> URL: https://issues.apache.org/jira/browse/CASSANDRA-2521
> Project: Cassandra
> Issue Type: Improvement
> Components: Core
> Reporter: Chris Goffinet
> Assignee: Sylvain Lebresne
> Fix For: 1.0
>
> Attachments:
> 0001-Use-reference-counting-to-decide-when-a-sstable-can-.patch
>
>
> http://wiki.apache.org/cassandra/MemtableSSTable
> Let's move to using reference counting instead of relying on GC to be called
> in StorageService.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira