From personal experience , java , minecraft or optifine is not the problem. The problem is windows 10 , it is not completely finished and it is not optimised for gaming. Personally, i had the same problem and after playing minecraft on windows 10 for about 2-3 months a recieved huge memory leak...