Comments (6)
Take a look at my alternative way to avoid bootstrapping Angular each time in issue #54
from golden-layout.
Thanks, but in my case bootstraping angular in each tab is necessary... Indeed, I use the tabs exactly as webbrowser tabs so my app can be opened many times (if I bootstrap it once, a lot of conflicts would appear (listeners, variables, etc...)!).
I started with iframes but got into troubles (#34) so I followed your advice and bootstrap each tab. This works great except for @media (#51) and the leaks.
from golden-layout.
Do you have hanging DOM nodes? In modern JS browsers, DOM nodes can have "retaining paths". For example if you have a reference var foo = jQuery('.foo')
, and then you remove the element from the DOM but do not cleanup the JS variable "foo", you retain "hanging DOM nodes" in memory.
I'm not familiar with your particular issue, but this article helped me solve similar problems in other code - http://addyosmani.com/blog/taming-the-unicorn-easing-javascript-memory-profiling-in-devtools/
For example, you didn't mention if you tried to force GC in the devtools. GC only happens every so often, and memory may appear to steadily increase prior to a GC invocation, with no correlation to the presence/absense of memory leaks. GC can be delayed for a very long time due to any number of reasons such as the thread not being idle, or not enough garbage having accumulated yet, as far as I know the browser makes no guarantees about when the memory is actually free'd. Even after a GC cycle occurs or is forced, not all garbage may be processed. It may take multiple such cycles to free up all memory, as far as I know. Also, if you're able to compare snapshots before & after & find the specific DOM nodes or other type(s) of garbage that is left over, that should help expedite a fix for this.
I also second the notion about bootstrapping tabs multiple times. I've never encountered a need to bootstrap multiple apps, where I couldn't just write a new directive that wraps them into a single new app & bootstrap that 1x. It may work, its just not the "Angular" way IMO. If you need initialization logic, its best to insert a directive into each tab using the $compile
service, and put the initialization logic in a directive's link/controller functions:
Here's a golden layout component:
myLayout.registerComponent( 'template', function( container, state ){
$http.get(state.templateId, {cache:true}).success(function(html) {
html = $compile('<div>'+html+'</div>')($rootScope);
container.getElement().html(html);
container.on( 'resize', function(){
$(window).trigger( 'resize' );
});
});
});
Use like this:
var myLayout = new GoldenLayout({
settings: {
showPopoutIcon : false
},
content: [{
type: 'row',
isClosable: false,
content: [{
type: 'component',
title: 'hello world!',
componentName: 'template',
componentState: { templateId: 'foo/bar.html' },
isClosable: false
}]
}]
});
It should fetch the template 1x per session via $http & cache it. It will "bring to life" any directives found in the template via running it through $compile service, and bind the resize events which should help with any AngularJS/jQuery plugins.
from golden-layout.
@natcohen Did you manage to solve this?
from golden-layout.
@Jmales No...
from golden-layout.
@natcohen Ty for the answer. How come it was closed then?
2 years later and I'm also having memory leaks with GL when using angular: #216
from golden-layout.
Related Issues (20)
- Is it possible to set the height of the container higher than the browser window?
- Maximizing in the official "Adding items to a predefined layout" CodePen doesn't work HOT 2
- Having issue on tab overlaping
- `ContentItem.getItemsById` is absent in code but present in docs
- Migrating stackCreated event in golden-layout 2 HOT 1
- createAndInitContentItem() should take an unresolved config.
- No header controls in basic implementation HOT 3
- Bugs in negated `instanceof` expressions
- Unable to add child items
- How i can remove created DragSources?
- Popouts are not handled in loadLayout correctly
- popout not working when using with popoutWholeStack enabled
- The position when closing the tab when reopening it HOT 1
- Way to prevent tab drag to other component [HELP] HOT 1
- RTL Feature Support HOT 1
- isClose cause issue with dragging
- X3D content fails after dragging window
- Is it possible to simulate a new window on this page instead of using the browser implementation?
- it popout the whole application gets loaded in popup window
- Error: Component type not registered and BindComponentEvent handler not assigned HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from golden-layout.