1. #1
    Ext User cluettr's Avatar
    Join Date
    Apr 2007
    Location
    Boston, MA
    Posts
    336
    Vote Rating
    0
    cluettr is on a distinguished road

      0  

    Default Variable Placement? Controlling Memory Usage.

    Variable Placement? Controlling Memory Usage.


    All,

    I am no expert, not even intermediate but I've got the hang of ext and javascript enough to be both dangerous and successful. My question is more javascript focused rather than Ext focused. However, I'm sure every ext novice might run into what I am running into and look for a solution.

    When performing an XHR I often have the Ext.OnReady and/or particular functions in script tags at the beginning of the called script. I never felt it was the cleanest method. What I am finding is that memory is being crushed and my thoughts are that this method is not allowing IE to allocate and deallocate memory as it should.

    Is it that I am initializing and assigning values to variables in the called script and calling them over and over again? Should the variables be initialized globally to avoid this issue? I hope an expert is understanding what I am trying to say here and might be able to give me some advice. Thank you in advance.

    Rob

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,483
    Vote Rating
    35
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    I think that page fragments which are loaded through Ajax (XHRs) should be generated by code that is aware that it is only producing a page fragment and not a document.

    This means that there should be no Ext.onReady produced.

    It also means that where javascript is embedded in the fragment, the code production engine needs to be fully aware of the API supplied by your javascript application singleton that is in control of your main page. The code production engine should produce code which hooks into the application singleton to integrate any new UI elements being instantiated into the application's UI management.

    What this means is that you have to have an integrated set of classes on your server which have been written by the same person who wrote your javascript.

    Things have not progressed in terms of tools in this area, but I think they could a lot more.

    These are the kind of problems that I see cropping up here over and over again.

    People produce full HTML documents from "old fashioned" PHP scripts, JSP pages, ASP pages etc to be loaded into Panels, but they don't seem aware (or conveniently forget) that these panels are merely cleverly rendered divs, which share an id space, but do not share javascript context.

  3. #3
    Ext User cluettr's Avatar
    Join Date
    Apr 2007
    Location
    Boston, MA
    Posts
    336
    Vote Rating
    0
    cluettr is on a distinguished road

      0  

    Default


    Hi Animal. Thanks for the response. I have to be honest though, I don't understand a word of what you just wrote

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,483
    Vote Rating
    35
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    What I'm basically saying is that you can't just splurge out pages from your server that just assume they are pages.

    Any javascript code in them must be aware that it is being loaded inside an existing Ext application, and must "register" with that and cooperate with it.

    The way we have it is that you can request eg "/aspicio/Component.launch?component=Country" from the browser's URL bar, and it will output a full document, with an Ext.onReady script that starts up Ext, creates a BorderLayout, and does country maintenance in the center region.

    But if you select "Country Maintenance" from the menu, it will Ajax-load that same URL, but recieve different content. It will be content that just loads just the country maintenance bit into the center area.

    People insist that they are loading script "into" a tab, or a panel. That is not the case, they are merely calling up script from the server. And if it's static script, then they might as well include it in the main page and call it. If it's generated, then it has to be generated by an engine that knows about the environment that it is creating code for.

  5. #5
    Ext User cluettr's Avatar
    Join Date
    Apr 2007
    Location
    Boston, MA
    Posts
    336
    Vote Rating
    0
    cluettr is on a distinguished road

      0  

    Default


    OK, I think I follow. What you are saying is that your applications javascript must be written in such a way that it has full control over it. In other words if you are going to have javascript interact with HTML loaded via an XHR it should be outside the Ajax loaded HTML.

    I ran into this issue with timers. If i had a variable defined within the HTML loaded via an XHR it just kept creating timer after timer. If I moved the initialization of the variable back to the control functions outside of the XHR and merely assigned it timers within the XHR it worked without issue. This is what leads me to beleive that you cannot define a variable time and time again within the XHR loaded HTML else the DOM holds several instances of it and you can no longer null those variables and do the necessary clean up work.

    Would embedding javascript in the Ajax loaded HTML cause the type of issue I am referring to. Memory usage creeps up with each call until if finally renders the application unsuable. Only closing and reopening the browser will solve this problem?

  6. #6
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,483
    Vote Rating
    35
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    The control is outside of the loaded code. There is a single application controller.

    I think you've hit one of the crucial design issues: Loading a "page" over and over and the "page" just runs its own scripts creating things as if it was the owner of the document, and pretty soon, the page would be discarded (by a form submission, or clicking a link), and another page would take its place.

    This no longer happens. The new style web app is a single, long-lived page.

    If you are loading a static HTML page over and over, that's a design mistake. Once information is inside your app, you no longer need to get it from the network.

  7. #7
    Ext User cluettr's Avatar
    Join Date
    Apr 2007
    Location
    Boston, MA
    Posts
    336
    Vote Rating
    0
    cluettr is on a distinguished road

      0  

    Default


    This conversation is touching on topics that I've questioned... this is good.

    The control is outside of the loaded code. There is a single application controller.
    I have a single page which carries most of the javascript. Embedded in that page is a single div which holds the layout for various applications. I switch from application to application and that div is loaded with new HTML each time.

    I think you've hit one of the crucial design issues: Loading a "page" over and over and the "page" just runs its own scripts creating things as if it was the owner of the document, and pretty soon, the page would be discarded (by a form submission, or clicking a link), and another page would take its place.
    The design I went with was one page that is never reloaded at any point. switching pages, submitting forms, etc. etc... are all done via an XHR

    This no longer happens. The new style web app is a single, long-lived page.If you are loading a static HTML page over and over, that's a design mistake. Once information is inside your app, you no longer need to get it from the network.
    Yes, I do beleive I have a design flaw here. I guess what I should be doing is merely populating the div with the HTML which is predefined at page load. Then merely load the data via an XHR on an as needed basis. Doesn't this get quite messy on large apps though?

  8. #8
    Ext User
    Join Date
    Nov 2008
    Posts
    6
    Vote Rating
    0
    Mirux is on a distinguished road

      0  

    Default


    Hello Animal, thanks for the response. This thread cleared my mind but I'd still like to know your opinion about a method I am using:

    As you said, in a TabPanel, inside each Tab, there's a panel which renders a <div> with a certain id.

    What I am doing is, every time I click on the west panel links, I open a new tab on center panel with content I get from a php file via XHR, (autoLoad: {}). I am not sure if this is a good method, I'd appreciate reading your opinion about it.

    Seems to be a good method to me since everytime you request the php file, it is reloading the page over and over again, which is exactly what you mean when you're getting content that is being modified or updated, eg: Getting data from a database and tabulate it.

    Thanks in advance.

  9. #9
    Ext User Slimsuperb's Avatar
    Join Date
    Nov 2008
    Location
    Nigeria
    Posts
    7
    Vote Rating
    0
    Slimsuperb is on a distinguished road

      0  

    Default Image Uploading in EXT

    Image Uploading in EXT


    thread deleted by moderator

    @Slimsuperb. Do not hijack existing threads to ask a completely off topic question. Please post your question in a new thread.

  10. #10
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    2
    tryanDLS is on a distinguished road

      0  

    Default


    I think something you also need to consider is proper destruction of objects. If you're loading stuff into a panel(div) and building Ext components, then further along making another call to load new stuff into the same container, without cleaning up, you're going to have memory issues. If you're in essence just dumping the entire (possibly very complex) innerHTML of a container without cleaning up references, you're asking for trouble.

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar