Skip to content

BUG/memory usage: OpamConsole.log and OpamFile.Stats #6484

Description

@hannesm

Dear everyone,

thanks for your time to read this bug report.

So, I have an application (https://github.com/hannesm/maintenance-intent-filter) using opam as a library - and discovered there are some heavy memory usages.

The root cause are two things:

  • (a) 84a3d28 (part of Implement CLI versioning #4316) which "queues up OpamConsole messages if OpamCoreConfig.set has not been called". Now, in my application there's nothing calling OpamCoreConfig.set -- so these messages are queued up forever.
  • (b) OpamFile.Stats.read_files (a list of strings) getting extended in OpamFile.MakeIO().read_opt - and never gets cleared (nor uniquified)

I was wondering whether for (a) a bounded queue could be used? And for (b), could that be only added if r.print_stats is true -- otherwise these mutable lists are never used. Or could that code be removed entirely, if not used?

FWIW, in Stats.print there's an error:

  let print () =
    let aux kind = function
      | [] -> ()
      | l  ->
        OpamConsole.msg "%d files %s:\n  %s\n"
          (List.length !read_files) kind (String.concat "\n  " l)
    in
    aux "read" !read_files;
    aux "write" !write_files

The List.length uses always the !read_files - while it should use l.

If you can decide on acceptable ways forward for both (a) and (b), that would be fantastic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions