我已将有问题的代码隔离到此函数(使用 ASP.NET 的 Membership 类):
let dbctx = DBSchema.GetDataContext()
let rec h1 (is2_ : int) (ie2_ : int) : unit =
match is2_ >= ie2_ with
| true ->
let st2 = query {
for row in dbctx.Tbl_Students do
where (row.Id = is2_)
head}
let l2 =
Membership.FindUsersByEmail (st2.Email_address)
|> Seq.cast<_>
|> Seq.length
match l2 >= 1 with
| true ->
()
| false ->
Membership.CreateUser (st2.Email_address, password, st2.Email_address)
|> ignore
h1 (is2_ - 1) ie2_
| false ->
()
我得到System.OutOfMemoryException
了. 但我系统的内存消耗仅为. (我有一台非常强大的 16 GB 机器。)5626
h1
20 percent
为什么上面的函数会溢出堆栈?不是递归写成tail吗?
在此先感谢您的帮助。