Log in or register to post comments

Receive Memory Warning in iPod 4G

February 19, 2014 - 6:57pm #1

I get your sample and run. but in iPod 4G it crash when I scan 3-4 times.

Please help me know reason and How can I fix it??

Thanks.

Receive Memory Warning in iPod 4G

February 27, 2014 - 11:30pm #16

Hi Pierre,

Can you confirm that you also added the calls to destroyDataSet() in the method doUnloadTrackersData() ?

==> yes, I have added it.

Can you confirm that the dealloc of your (AR) ViewController is never called?

==> I debuged and dealloc in ImageTargetsViewController class nerver be call. so After open camera and back to previous view Memory increase..

See attachment above, run your app and check.

Please check it.

The second problem is with the observers which are set in the constructor of the ViewController.

==> I do follow you, it isn't solve problem.

 

 

Receive Memory Warning in iPod 4G

February 25, 2014 - 2:59pm #15

Hi Hvar,

 

Can you confirm that the dealloc of your (AR) ViewController is never called?

We have references to the ViewCiontroller which may prevent this ViewController to be deallocated.

 

If you confirm that your ViewController is not deallocated, there are 2 changes you may want to do.

 

In SampleApplicationSession.mm, you need to change the property from reatin to assign :

 

// SampleApplicationControl delegate (receives callbacks in response to particular
// events, such as completion of Vuforia initialisation)

@property (nonatomic, assign) id delegate; 

 

The second problem is with the observers which are set in the constructor of the ViewController. The purpose of those observers is to make sure that we proper pause and resume Vuforia when the application goes in the background or is reactivate.

 

The issue is that those observers are using blocks and the side effect of those is that the block keep a 'hiiden' reference to self (the ViewController) which then prevent this ViewController to be deallocated.

The fix is simple: instead of using blocks, you can use selectors.

 

To do that, you need the methods to handle those notifications:

- (void) pauseAR {
    NSError * error = nil;
    if (![vapp pauseAR:&error]) {
        NSLog(@"Error pausing AR:%@", [error description]);
    }
}

- (void) resumeAR {
    NSError * error = nil;
    if(! [vapp resumeAR:&error]) {
        NSLog(@"Error resuming AR:%@", [error description]);
    }
    // on resume, we reset the flash and the associated menu item
    QCAR::CameraDevice::getInstance().setFlashTorchMode(false);
    SampleAppMenu * menu = [SampleAppMenu instance];
    [menu setSelectionValueForCommand:C_FLASH value:false];
}

and then, to change the observer definition in the constructor of the ViewController to be:

        [[NSNotificationCenter defaultCenter]
             addObserver:self
             selector:@selector(pauseAR)
             name:UIApplicationWillResignActiveNotification
             object:nil];
        
        [[NSNotificationCenter defaultCenter]
         addObserver:self
         selector:@selector(resumeAR)
         name:UIApplicationDidBecomeActiveNotification
         object:nil];

instead of the blocks code which was there before.

 

In the dealloc of your ViewController, the code then becomes:

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [tapGestureRecognizer release];
    
    [vapp release];
    [eaglView release];
    
    [super dealloc];
}

To be safe, you should remove the member variables backgroundObserver and activeObserver from your .h

-    id backgroundObserver;
-    id activeObserver;

 

Those leaks are unfortunate and not detected by Instruments.

 

In order to validate this change, run your application in the debugger and check that dealloc is called on your ViewController.

 

If not... tell us here.

 

Thanks

 

Pierre

 

 

 

Receive Memory Warning in iPod 4G

February 25, 2014 - 7:09am #14

Hi,

Can you confirm that you also added the calls to destroyDataSet() in the method doUnloadTrackersData() ?

Thanks

Pierre

Receive Memory Warning in iPod 4G

February 24, 2014 - 7:13pm #13

Hi,

This is analy of this project . I attach above.

Thanks.

 

Receive Memory Warning in iPod 4G

February 24, 2014 - 6:53pm #12

Hi,

i was asking for the result of the Xcode analyzer not the instruments result. Iirc, the analyzer is in the menu 'products/analyze'

 

pierre

Receive Memory Warning in iPod 4G

February 24, 2014 - 6:22pm #11

Hi I attach screenshot above, please see it.

Receive Memory Warning in iPod 4G

February 24, 2014 - 7:07am #10

Hi Fvar,

 

Could you post here or send by message, the result of the XCode analyzer ?

Thank you

Pierre

Receive Memory Warning in iPod 4G

February 24, 2014 - 2:18am #9

Please see it and give me your suggestions.

Thanks

Receive Memory Warning in iPod 4G

February 24, 2014 - 2:17am #8

Thanks your reply.

I fix with your suggestion. But I still meet a problem with Receive Memory Warning. 

My app just add ImageTarget, no sliding menu.

step by step:

1. run app.

2. go to AR screen (Camera screen).

3. back to previous page.

4. repet step 2and 3 >10 times.

5. App show Receive Memory Warning.

 

I attach for you Leak memory when I run Instrument. 

Please see it.

 

Receive Memory Warning in iPod 4G

February 21, 2014 - 8:04am #7

Hi Fvar,

I have 3 suggestions for you.

Even though you removed the "sliding menu" UI component which has indeed a couple of memory leaks, I strongly suggest that you run the code analyzser from XCode (Product/Analyze) - this analyzer will clearly show you if you have memory leaks in your code.

Another suggestion is to explicitely destroy your datasets in the doUnloadTrackerData method (see code in green - to be changed with your datasets of course) :

- (bool) doUnloadTrackersData {
    [self deactivateDataSet: dataSetCurrent];
    dataSetCurrent = nil;
    
    // Get the image tracker:
    QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();
    QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(trackerManager.getTracker(QCAR::ImageTracker::getClassType()));
    
    // TO ADD:
    // Destroy the data sets:
    if (!imageTracker->destroyDataSet(dataSetTarmac))
    {
        NSLog(@"Failed to destroy data set Tarmac.");
    }
    if (!imageTracker->destroyDataSet(dataSetStonesAndChips))
    {
        NSLog(@"Failed to destroy data set Stones and Chips.");
    }
    
    NSLog(@"datasets destroyed");
    return YES;
}

A final suggestion would be to call freeOpenGLResources when your AR view disappear:

- (void)viewWillDisappear:(BOOL)animated {
    [vapp stopAR:nil];
    // Be a good OpenGL ES citizen: now that QCAR is paused and the render
    // thread is not executing, inform the root view controller that the
    // EAGLView should finish any OpenGL ES commands
    [eaglView finishOpenGLESCommands];

    // TO ADD:
    [eaglView freeOpenGLESResources];
}

 

Post the results of those changes for your application here,

Thanks

Receive Memory Warning in iPod 4G

February 21, 2014 - 2:47am #6

Hi,

I have modified Image Target source code with no Sliding Menu system and it still crash.

Can you check it soon? because my dealine for my project in next several day.

Thank so much.

Receive Memory Warning in iPod 4G

February 21, 2014 - 1:55am #5

This is the same problem as reported here:

https://developer.vuforia.com/forum/ios/videoplayback-memory-problem

 

..and this is to do with the Sliding Menu system.

The development team are aware of this and are aiming to fix this in a forthcoming release.

In the meantime I will try to see if there is a workaround.

 

thanks

N

Receive Memory Warning in iPod 4G

February 20, 2014 - 11:03pm #4

I get sample Image Target in here (iOS) : https://developer.vuforia.com/resources/sample-apps/image-targets-sample-app

Now I use iPod 5(iOS 7), run sample VuforiaSamples in VuforiaSamples-2-8-9.

Step to repoduce:

1. Lanch app.

2. select "Image Targets".

3. select "Start".

4. open Menu and select "Image Targets" 

5. select "Start"

6. repet (step 4 and 5) 10-12 times.

==> App crash.

Please help me fix it.

Receive Memory Warning in iPod 4G

February 20, 2014 - 11:03pm #3

I get sample Image Target in here (iOS) : https://developer.vuforia.com/resources/sample-apps/image-targets-sample-app

Now I use iPod 5(iOS 7), run sample VuforiaSamples in VuforiaSamples-2-8-9.

Step to repoduce:

1. Lanch app.

2. select "Image Targets".

3. select "Start".

4. open Menu and select "Image Targets" 

5. select "Start"

6. repet (step 4 and 5) 10-12 times.

==> App crash.

Please help me fix it.

Receive Memory Warning in iPod 4G

February 20, 2014 - 2:58am #2

I get your sample and run

Which sample?

 

in iPod 4G it crash when I scan 3-4 times.

Please provide exact steps to reproduce, also which sub-sample was it?

 

Which iOS?

Have you tried on any other devices?

 

N

Log in or register to post comments