Merging files gives memory allocation error
You could try something like this :

First you should work with the same class of object : data.table for fast merging operation

# Turning a to a data.table
setDT(a)
# b is already a data.table 


Then you might have to set the keys of both table : 

# I added chr in case you need to match the same position on a different chromosome.
setkey(a, chr, position)
setkey(b, chr, position)


Finally perform the joining operation :

a[b, nomatch=0]


Because you didn't provide the expected output, it might need some tuning !