Skip to content

[BUG] Extreme memory usage during rendering #823

@shivabhusal

Description

@shivabhusal

The following slim partial used 38GB RAM in Mac and 8GB in linux.

.drivers-view
  h2.title Drivers
  .actions
    //= link_to 'Add New Driver', new_driver_path, class: 'button'
    button.add onclick="window.location.href='/drivers/new'"
      ' Add new driver
    button#saveDriverButton disabled="true"
      '  Save

  - if @drivers.empty?
    p Your organization has no drivers.
  - else
    .table-box
      .table-scroll
        table
          thead
            tr
              th.text-center width="50" ID
              th Name
              th Image
              th Phone
              th OTP
              th Preferred base
              th Available time
              th Available days
              th Status
              th.text-center width="80" Actions
          tbody
            - @drivers.each do |driver|
              tr
                td
                  = driver.id
                td
                  = driver.name
                td
                  .driver-image
                    = image_tag driver.avatar.url(:medium), alt:( (driver.name) ? driver.name[0..1] : 'N/A')
                td
                  = driver.phone
                td
                  = driver.otp
                td.preferred-hub
                  = select_tag 'preferred_hub',  options_from_collection_for_select(::Base.sorted, 'id', 'name', driver.preferred_base_id.try(:to_s)),
                              class: 'custom-select', data: {worker_id: driver.id},
                              prompt: 'Select a Hub'
                  //i.fas.fa-angle-down
                td
                  = driver.time_available
                td
                  = driver.days_available
                td
                  - if driver.status
                    .label class=driver.status
                      = driver.status.humanize
                td.text-center
                  = link_to edit_driver_path(driver)
                    i.fas.fa-pencil-alt
                  = link_to generate_otp_driver_path(driver), class: 'margin15left', title: 'Regenerate OTP', method: :put do
                    i.fa.fa-sync

Problem

                  = if driver.status
                    .label class=driver.status
                      = driver.status.humanize

Solution

                 - if driver.status
                    .label class=driver.status
                      = driver.status.humanize

I have used = instead of - before if.

Conclusion

Its fixed now, but I expect SLIM to handle this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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