When the superior court shall have evidence from any judicial proceeding had before it that a person within this state is illegally confined or restrained of his liberty, such court shall issue a writ of habeas corpus for his relief, although no application be made for such writ. If the writ is granted by the court on its own motion, no fee shall be allowed.
N.J.S. § 2A:67-3