hi all,
I've tried as suggested by jason with this semplified piece of code:
public class MainEntryPoint implements EntryPoint{
private Marker marker;
private MapWidget map;
public MainEntryPoint() {
}
/**
* The entry point method, called automatically by loading a
module
* that declares an implementing class as an entry-point
*/
public void onModuleLoad() {
map = new MapWidget(LatLng.newInstance(38.1890087,
15.5648162), 12);
map.checkResizeAndCenter();
RootPanel.get().add(map);
Timer t = new Timer(){
@Override
public void run() {
for (int i = 0; i < 10; i++)
{
map.clearOverlays();
map.addOverlay(createMarker());
}
}
};
t.scheduleRepeating(3000);
//180209Miki:per prima cosa devo caricare le api
*dinamicamente*
//...poi tutto il resto di conseguenza
//lookupKey(Window.Location.getHost());
}
public Marker createMarker()
{
marker = null;
marker = new Marker(LatLng.newInstance(new Double(15), new
Double(38)));
return marker;
}
}
I would expect memory doesn't increase.. it doesn't
clearOverlays does not remove references with ie7
any workaround...?
please help, thx,
Michela
On 24 Feb, 20:22, koalina <[email protected]> wrote:
> commenting the addOverlay, memory usage is costant...
> that's why i think there's something wrong with the clearOverlays..
> thx for help,
> michela
>
> On Feb 24, 5:47 pm, Eric Ayers <[email protected]> wrote:
>
> > Yeah, you are right.
>
> > One thing you could try is to comment out the 'addOverlay()' call and
> > measure your memory again. You won't see anything, but it will tell
> > you if this is the problem.
>
> > On Tue, Feb 24, 2009 at 11:39 AM, koalina <[email protected]> wrote:
>
> > > but i call the clerOverlays each time i run the timer.. at each loop
> > > the markers should be deallocated... aren't they?
> > > Michela
>
> > > On 24 Feb, 17:31, Eric Ayers <[email protected]> wrote:
> > >> Think about what your code is doing here.
>
> > >> You are allocating marker objects and adding them to the map every
> > >> time your timer expires.
> > >> The map will track these things for you until you call
> > >> map.removeOverlay().
>
> > >> My guess is that you have hundreds of markers added to the map, all
> > >> stacked on top of each other.
>
> > >>http://gwt-google-apis.googlecode.com/svn/javadoc/maps/1.0/index.html
>
> > >> On Tue, Feb 24, 2009 at 6:57 AM, koalina <[email protected]> wrote:
>
> > >> > Hi all, I've found the cause of the memory leak isolating by some
> > >> > piece of code. It seems not to be caused by gwt-ext but when I make
> > >> > the map.addOverlay(createMarker(point, myObject));
>
> > >> > where createMarker is:
>
> > >> > Icon icon = Icon.newInstance(baseIcon);
>
> > >> > icon.setImageURL(GWT.getModuleBaseURL()+"images/"+getColor
> > >> > (nave)+"_ship.png");
>
> > >> > GWT.log("Carico immagine "+icon.getImageURL(), null);
> > >> > LabeledMarkerOptions options = LabeledMarkerOptions.newInstance
> > >> > ();
> > >> > options.setTitle(nave.getNomeNave());
> > >> > options.setIcon(icon);
>
> > >> > options.setLabelText(String.valueOf(nave.getIdNave()));
>
> > >> > options.setLabelClass("labeledMarker");
>
> > >> > //200209Miki: se l'id nave è lungo una solo cifra va bene
> > >> > così...
> > >> > if((Integer.toString(nave.getIdNave())).length()==1)
> > >> > options.setLabelOffset(Size.newInstance(1, -26));
> > >> > //altrimenti devo shiftare la label di due posti a sinistra...
> > >> > else
> > >> > options.setLabelOffset(Size.newInstance(-2, -26));
> > >> > //
>
> > >> > LabeledMarker marker = new LabeledMarker(point, options);
>
> > >> > ((Marker)marker).addMarkerClickHandler(new MarkerClickHandler
> > >> > () {
>
> > >> > public void onClick(MarkerClickEvent event) {
> > >> > //050209Miki: gestisco qui il popup informativo
> > >> > InfoWindow info = map.getInfoWindow();
> > >> > info.open(event.getSender(),
>
> > >> > new InfoWindowContent(
> > >> > "<div style='width:150px;height:65px; font-size:12px'
> > >> > " +
> > >> > "class='info-window'>" +
> > >> > //"<p><img width='35px' src='"+GWT.getModuleBaseURL()
> > >> > +"'images/logonave.png' align='left'></p>" +
> > >> > "Nome nave: <b>"+nave.getNomeNave()+"</b><br/>" +
> > >> > "Localita' Partenza: " +nave.getLocalitaPartenza()
> > >> > +"<br/>" +
> > >> > "Localita' Arrivo: "+nave.getLocalitaPartenza()+"<br/
> > >> >>" //+
> > >> > //"Merci Pericolose a Bordo: " +
> > >> > nave.getMerciPericolose()+"<br/></div>"
> > >> > ));
>
> > >> > }
>
> > >> > });
>
> > >> > return marker;
>
> > >> > It' squite strange but now I'm sure the issue is with this piece of
> > >> > code..
> > >> > is map.clearOverlays(); sufficient to deallocate the previous
> > >> > markers?
> > >> > thx,
> > >> > Michela
>
> > >> > On 24 Feb, 10:56, Alexey_Tsiunchik <[email protected]> wrote:
> > >> >> Hello,
>
> > >> >> We already have discussion about GWT memory management
> > >> >> here:http://groups.google.com/group/Google-Web-Toolkit/browse_thread/threa...
>
> > >> >> Tuesday, February 24, 2009, 11:31:44 AM, you wrote:
>
> > >> >> > I've tried reloading, I made a mistake some posts ago.. memory
> > >> >> > decreases only if the browser is closed and then opened again. Only
> > >> >> > reloading causes a bigger increment of memory usage.
> > >> >> > On 24 Feb, 10:20, koalina <[email protected]> wrote:
> > >> >> >> Hi alex,
> > >> >> >> sorry but I can't see how fix the number of rows as I'm using a
> > >> >> >> memoryProxy object.
> > >> >> >> So, the timer is defined as follows:
> > >> >> >> Timer t = new Timer() {
>
> > >> >> >> public void run() {
> > >> >> >> getShipInfo();
>
> > >> >> >> }
>
> > >> >> >> };
> > >> >> >> where getShipInfo() is
>
> > >> >> >> private void getShipInfo() {
>
> > >> >> >>
> > >> >> >> MainEntryPoint.getServiceWsNaviInMare().getInfoNaviInMare(new
> > >> >> >> AsyncCallback() {
>
> > >> >> >> public void onFailure(Throwable caught) {
> > >> >> >> throw new UnsupportedOperationException("Not
> > >> >> >> supported
> > >> >> >> yet.");
> > >> >> >> }
>
> > >> >> >> public void onSuccess(Object result) {
> > >> >> >> Vector listaNavi = (Vector) result;
> > >> >> >> GWT.log("Lista Navi Ricevuta:
> > >> >> >> "+listaNavi.toString(),
> > >> >> >> null);
> > >> >> >> if (listaNavi.size()>0) {
>
> > >> >> >> Object[][] data = new Object[listaNavi.size()]
> > >> >> >> [15];
> > >> >> >> Iterator i = listaNavi.iterator();
> > >> >> >> int index = 0;
>
> > >> >> >> while (i.hasNext()) {
> > >> >> >> Nave unaNave = (Nave) i.next();
> > >> >> >> data[index] = new Object[]{
> > >> >> >> unaNave.getIdNave(),
> > >> >> >> unaNave.getNomeNave
> > >> >> >> (),
>
> > >> >> >> unaNave.getLocalita(),
> > >> >> >> unaNave.getImbarco
> > >> >> >> (),
>
> > >> >> >> etc....
>
> > >> >> >> GWT.log("Nave "+data[index][0]+data[index]
> > >> >> >> [1].toString(), null);
>
> > >> >> >> index++;
> > >> >> >> unaNave = null;
>
> > >> >> >> }
> > >> >> >> if (store!=null) {
> > >> >> >> store.removeAll();
> > >> >> >> }
> > >> >> >> MemoryProxy proxy = new MemoryProxy(data);
> > >> >> >> ArrayReader reader = new
> > >> >> >> ArrayReader(recordDef);
> > >> >> >> store = new Store(proxy, reader);
> > >> >> >> store.load();
> > >> >> >> store.commitChanges();
>
> > >> >> >> grid.reconfigure(store, columnModel);
> > >> >> >> //240209Miki: x diminuire memory leak ...
> > >> >> >> grid.clear();
> > >> >> >> data = null;
> > >> >> >> proxy = null;
> > >> >> >> reader =null;
> > >> >> >> store = null;
>
> > >> >> >> }
> > >> >> >> }
>
> > >> >> >> });
>
> > >> >> >> }
>
> > >> >> >> I've tried with FF and there's no problem...so it's an issue with
> > >> >> >> ie7.
> > >> >> >> Can you see some big error in the code i posted just above? thx for
> > >> >> >> help!
> > >> >> >> Michela
>
> > >> >> >> On 24 Feb, 09:48, "alex.d" <[email protected]> wrote:
>
> > >> >> >> > Assuming adding/removing markers to/from the map is leakless
> > >> >> >> > (google
> > >> >> >> > probably knows how to do this ;-) we are left with gwt-ext grid.
> > >> >> >> > Every
> > >> >> >> > 10 sec you remove old rows and add new ones. So you have some
> > >> >> >> > DOM-
> > >> >> >> > Elements (a table row) that are removed/created every 10 seconds.
> > >> >> >> > Probably it's a grid's particular implementation that leaks. But
> > >> >> >> > most
> > >> >> >> > probably it's just IE that doesn't really remove garbage
> > >> >> >> > properly even
> > >> >> >> > when it can/should. So what can you do?
> > >> >> >> > 1. If it's grid that leaks: dump it - implement smth. yourself
> > >> >> >> > with
> > >> >> >> > vanilla GWT.
> > >> >> >> > 2. It it's IE: let's say the total ammount of markers is never
> > >> >> >> > bigger
> > >> >> >> > than 25 - you can create 25 rows in the table and instead of
> > >> >> >> > adding/
> > >> >> >> > removing them you just change the text. This way you'll have
> > >> >> >> > slightly
> > >> >> >> > more memory allocated at the beginning but hopefully no leaks
> > >> >> >> > while
> > >> >> >> > running because no DOM-Elements are created/removed.
>
> > >> >> >> > hth
>
> > >> >> >> > On 24 Feb., 09:14, koalina <[email protected]> wrote:
>
> > >> >> >> > > Hi Jason, yes, reloading page cause memory usage fall out.
> > >> >> >> > > My app is quite simple: a gwt ext tab panel, the first tab
> > >> >> >> > > showing the
> > >> >> >> > > map widget, the second one a gwt ext grid with a few rows
> > >> >> >> > > (more or
> > >> >> >> > > less 10), each one with some information about the markers
> > >> >> >> > > showed.
> > >> >> >> > > I've three "thread", implemented as Timer, which refresh
> > >> >> >> > > positions of
> > >> >> >> > > markers, informations and last update time. Each thread make a
> > >> >> >> > > rpc
> > >> >> >> > > call and is always running, even when the tab of interest is
> > >> >> >> > > not
> > >> >> >> > > active....
> > >> >> >> > > Do you see some critical issue in this
>
> ...
>
> leggi tutto
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---