Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 902551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:44:07+00:00 2026-05-15T15:44:07+00:00

We develop an application in an embedded environment. It is a high level computing

  • 0

We develop an application in an embedded environment. It is a high level computing environment with a complete webbrowser on top of a busybox Linux system. The only exception is that the system has a limited amount of system memory.

Our application is built in JavaScript and runs inside a Webkit based webbrowser and consists of a lot of javascript modules that are loaded in sequence (Which is not very efficient).

Some modules provide common functionality that is used by several modules. We are in the process of converting our current javascript loader with requirejs, but there is one specific need we have to address first.

Is it possible to unload a module when it has been loaded using requirejs? Assume that we dynamically loads a module using :

require(["somemodule.js"], function(m) { m.run(); } );

That works well for loading and running ‘somemodule’ and also resolving all dependencies for ‘somemodule’ and the requirejs framework will store a reference to ‘somemodule’ for future requests.

If we at some point need to reclaim memory, e.g to be able to load and run an infinite number of modules, we have to start removing some of them after some time. Is that possible with requirejs without altering the internal implementation?

Has anyone dealt with this kind of problem before? Most single page JS apps runs in a webbrowser on a desktop PC where memory usage usually is not a major concern.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T15:44:08+00:00Added an answer on May 15, 2026 at 3:44 pm

    RequireJS does not have a built-in unload feature, but it could be added perhaps as an additional part you could build into it. If you would like to have that feature, feel free to propose it in the mailing list or as a GitHub issue.

    If you wanted to experiment to see if it helps your situation, what you need to do is the following:

    1) Remove the defined module from the RequireJS module cache. If you are not using the multiversion support, you can do something like:

    var context = require.s.contexts['_'];
    delete context.defined[moduleName];
    delete context.specified[moduleName];
    delete context.loaded[moduleName];
    

    2) Then you can try removing the script tag to see if that helps:

    var scripts = document.getElementsByTagName('script');
    for (var i = scripts.length - 1; i >= 0; i--) {
        var script = scripts[i];
        if (script.getAttribute('data-requiremodule') === moduleName) {
            script.parentNode.removeChild(script);
            break;
        }
    }
    

    Note that the module may not be garbage collected if another module holds on to it via the closure function(){} that defines that other module. That other module would need to be removed too.

    You can try to limit that impact by not passing in the module as a function argument, but just use require(“somemodule”) inside the function definition whenever you want to get a hold of dependent modules, and not holding on to that require return value for too long.

    Also, in your example above, for modules that use require.def to define themselves, it should look like this (without the .js suffix):

    require(["somemodule"], function(m) { m.run(); } );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We develop an embedded Qt application for linux on MS Windows. The target platform
I need to develop an application in java, which uses a client[embedded server]-server-(-server)-(...) approach.
I'm developing application with Qt Embedded and run it in linux framebuffer. I need
I have been attempting to develop an embedded webserver within an application that I
I use play to develop my project and embedded netty3 as my application server
I'm using Eclipse to develop application for embedded systems. One of the options of
I'm trying to develop a GUI application for an embedded platform, without any windowing
I currently develop many applications in a Qt heavy C++/Python environment on Linux, porting
I am using VSTS 2008 with C# to develop Silverlight application embedded in web
I am fairly new to linux world, I have to develop an application on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.