Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Memory 为什么球拍在这里以不同的值开始(当前内存使用)?_Memory_Memory Management_Racket - Fatal编程技术网

Memory 为什么球拍在这里以不同的值开始(当前内存使用)?

Memory 为什么球拍在这里以不同的值开始(当前内存使用)?,memory,memory-management,racket,Memory,Memory Management,Racket,下面是一个程序prog.rkt,它打印Racket v7.3中无用线程的估计内存开销 #lang racket (define (make-wasteful-thread) (thread (lambda () (let l () (l))))) (define (estimate-thread-cost) (parameterize ([current-custodian (make-custodian)]) (collect-garbage) ; Removing thi

下面是一个程序
prog.rkt
,它打印Racket v7.3中无用线程的估计内存开销

#lang racket

(define (make-wasteful-thread)
  (thread (lambda () (let l () (l)))))

(define (estimate-thread-cost)
  (parameterize ([current-custodian (make-custodian)])
    (collect-garbage) ; Removing this line causes every other estimate to change
    (define th (make-wasteful-thread))
    (collect-garbage)
    (define cost (current-memory-use (current-custodian)))
    (kill-thread th)
    (custodian-shutdown-all (current-custodian))
    cost))

(for ([i (in-range 10)])
  (displayln (estimate-thread-cost)))
下面是在Arch Linux终端上使用
racket prog.rkt
运行时在我的系统上的程序输出

为什么只有第一行不同

15464
13400
13400
13400
13400
13400
13400
13400
13400
13400

你是在开终点站吗Racket博士?我分别得到4800和16304。所有的值都是一样的(macOS)。@soegaard我实际上也在macOS上测试过这个,使用7.0并创建可执行文件,我观察到了同样的情况。我复制了
制造浪费线程
,并在迭代中各做了一个,希望我能首先看到2个不同,但它们不是,但我也看到3个值,但与运行的值不一致。@soegaard在Arch Linux上的shell中使用
racket prog.rkt
。编辑问题以添加详细信息。似乎在我的机器上使用
raco make--disable inline
进行编译会使所有打印的值保持不变。