Hadithcore
Mishkat al-Masabih, 280

Abu Huraira reported God’s messenger as saying, "Knowledge from which no benefit is derived is like a treasure from which nothing is expended in God’s path.” Darimi transmitted it.

وَعَنْ أَبِي هُرَيْرَةَ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «مَثَلُ عِلْمٍ لَا يُنْتَفَعُ بِهِ كَمَثَلِ كَنْزٍ لَا يُنْفَقُ مِنْهُ فِي سَبِيل الله» . رَوَاهُ الدَّارمِيّ

References1 variant
In-Book Reference
Book 2, Hadith 75