-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unexpected allocation in this code #6357
Comments
I suspect this issue would be easier to address if you could include an example of complete code where GC is the main performance bottleneck and where GC could be turned off with provable safety. |
None of the code here does any form of new() but the memory increases significantly after looping for a short while. Disabling the GC also improves the performance significantly, please let me know if there is any code here that misuse more memory than it should.. [edit by @ihnorton: quotes around code] |
The compiler will generate code that allocates memory as necessary. If your data types store numbers, do their fields have specific declared types? If not, it will cause allocation of boxed numbers. |
I have declared types for all of them. So far, I am adding gc_disable() before each loop and gc_enable(), gc() after each loop. Maximum memory usage is 10GB now. I am pretty convinced that Julia needs a better GC to compete with Java... I hope gc improves soon, as I am currently using Julia for a really huge project. |
As it happens, there is already a large GC improvement waiting to be merged here: #5227 The |
I find the Profiler + ProfileView is the easiest way to figure out problematic lines: it will highlight in red any lines that trigger garbage collection. |
abstract EdgeAbstract type Bus_Stop type Edge <: EdgeAbstract I have isolated the problem. It is this circular dependency that is currently not supported in Julia that causes the loosely typed code and memory allocation problem. I subsequently remove the circular dependency and the abstract type. Now the code works fast. So GC does not work well for circular dependency... |
The GC handles circular references just fine. The problem is that Bus_Stop is not a concrete type. See a lengthy explanation here: You should make your |
For example:
|
Some of my functions contains a loop that operates on an array which occupies a big chunk of memory. But no data is created or destroyed in those loops. Julia should detect that and avoid calling the GC in these loops. This will significantly improve performance. Infact, knowing when to call GC can lead to significant improvements in the code execution.
The text was updated successfully, but these errors were encountered: