Yes, we should probably have a manual chapter on memory management.

On Tue, Jul 8, 2014 at 12:46 PM, Abraham Egnor <abe.eg...@gmail.com> wrote:

> Mostly I was looking for documentation on performance characteristics,
> although I'd settle for anything at all :)  The Julia home page and manual
> have zero mention of memory management that I could find, except for a FAQ
> entry about unbinding large values in the REPL.  I inferred GC but the
> runtime could also have been using refcounting, region inference, or
> something more exotic.
>
>
> On Tue, Jul 8, 2014 at 1:26 PM, Patrick O'Leary <patrick.ole...@gmail.com>
> wrote:
>
>> You may also find this pull request interesting:
>> https://github.com/JuliaLang/julia/pull/5227
>>
>>
>> On Tuesday, July 8, 2014 11:31:12 AM UTC-5, Abraham Egnor wrote:
>>>
>>> Are there any plans to document the Julia GC (i.e. your comment implies
>>> that it's a stop-the-world GC) and/or add performance tuning knobs?
>>>
>>>
>>> On Tue, Jul 8, 2014 at 12:17 PM, Stefan Karpinski <ste...@karpinski.org>
>>> wrote:
>>>
>>>> Writing `A = nothing` in Julia will not cause the memory used by A to
>>>> be freed immediately. That happens in reference counted systems, which many
>>>> dynamic languages traditionally have been, but which Julia is not. Instead,
>>>> the memory for A will be freed the next time a garbage collection occurs.
>>>> This consists of the language runtime stopping everything it's doing,
>>>> tracing through the graph of all objects in memory, marking the ones it can
>>>> still reach, and freeing all the rest. So if doing `A = nothing` causes
>>>> there to be no more reachable references to the object that A used to point
>>>> at, then that object will be freed when the next garbage collection occurs.
>>>> Normally, garbage collection occurs automatically when the system tries to
>>>> allocate something and doesn't have enough memory to do so: it runs the
>>>> garbage collector and then tries again. You can, however, call gc() to
>>>> force garbage collection to occur now. This is generally not necessary or
>>>> recommended.
>>>>
>>>>
>>>> On Mon, Jul 7, 2014 at 11:04 PM, Ivar Nesje <iva...@gmail.com> wrote:
>>>>
>>>>> In julia we don't say you shouldn't do something that could give
>>>>> better performance (if you really want it). The thing is that Julia uses
>>>>> automatic garbage collection because it is a pain to do manually, and then
>>>>> you have to live with the semantics of a garbage collector.
>>>>>
>>>>> If your program is not really constrained by memory in the second
>>>>> part, I would guess that it is unlikely that it would matter to your
>>>>> program when the arrays are released. Freeing memory in julia (and other 
>>>>> GC
>>>>> based languages), is about ensuring that no references remains to the
>>>>> allocated object.
>>>>>
>>>>> If it is a global variable, you can assign `nothing`, and if it is a
>>>>> global constant, you can change the type, so you must reassign it to a
>>>>> smaller array with the same dimensionality and type and ensure that you
>>>>> don't have local variables that references the same array.
>>>>>
>>>>> If it is a local variable, I'm not sure there is other options than to
>>>>> arrange the function boundaries, so that the large array goes out of scope
>>>>> when it is not needed any more.
>>>>>
>>>>> kl. 22:56:35 UTC+2 mandag 7. juli 2014 skrev Pablo Zubieta følgende:
>>>>>
>>>>>> Let's say I have some large matrices I need to do some calculations
>>>>>> and I use them in order to get some results that I will use in a second
>>>>>> part of a computation where I not longer need the initial matrices. 
>>>>>> Suppose
>>>>>> also that I preallocate those matrices.
>>>>>>
>>>>>> Would it be ok to bind the names of those matrices to nothing (or
>>>>>> something similar) from the moment I won't be using them anymore, or 
>>>>>> should
>>>>>> I leave the deallocation work to the GC?
>>>>>>
>>>>>
>>>>
>>>
>

Reply via email to