Software Archive
Read-only legacy content
17061 Discussions

R6025 - pure virtual function call,, Unity crashes

Akshay_A_
Beginner
2,067 Views

hi all

I am currently working on face recognition on the R2 release in Unity.. At one place i am trying to load another scene by pressing on a button and it is resulting in an error .ie.

Runtime Error!

R6025 - pure virtual function call

and then unity crashes.. the button has a different script attached to it. and also i am using  my face recognition camera to use  by using dontdestroyonload function and in that script which is attached to the button i am destroying the camera object such as no two camera may exist in one scene... 

plz can anyone help me??..


thanks.
Akshay 

0 Kudos
11 Replies
MartyG
Honored Contributor III
2,067 Views

Ok, I can understand, I think, why you are using the DontDestroyOnLoad function.  You want to change the scene but have your camera-driven object remain in the same position on the screen when the new scene loads in?

As for destroying the camera object ... do you mean the game camera that shows the user the view of what it is seeing?  If so, I can understand about not having two of these cameras active in the same scene, as Unity says that there is already a camera with an audio listener in the scene and that you should remove one of them.

You can have more than one camera in a scene though.  You just need to look at the camera's settings in the Inspector panel un-tick the "Audio Listener" option on all of the cameras except your main game one.

Also remember that when you create a new scene, a "Main Camera" is automatically created.  If you are going to import into that scene an object that already has a camera attached then just delete this Main Camera.  Then you would not have to use a script to destroy the camera.

Regarding loading in a new scene: in my own project, I used this JavaScript script on my title screen to change to another scene when the button was left-clicked on with the mouse.

function OnMouseDown() {
Application.LoadLevel ("NAME OF SCENE FILE");
}

Make sure that you have added each of your scenes to the "build list", which you use when your project has more than one scene file.  In each of your scene files, go to the 'File > Build Settings' menu option to open the pop-up build window and then click the "Add Current" button to add that scene name to the build list.  Unity will then know how to move from one scene to another when your button is clicked.  

Your list should have both the scene file with the button on it and the scene that you want to go to when the button is clicked.  It is like creating a link on a website.

Best of luck!

0 Kudos
Akshay_A_
Beginner
2,067 Views

@Marty well thanks for your guidance..

i just fixed that error by loading a script on my welcome screen camera such as if that scene is loaded again from the last scene after face recognition  and the camera from the face recognition is still appearing in my welcome scene where i dont want it then i use a script which destroys that camera which was using the face recognition script and everything now works fine..


 

0 Kudos
MartyG
Honored Contributor III
2,067 Views

I'm happy you found a solution.  Good luck with the rest of your project, Akshay!

0 Kudos
Akshay_A_
Beginner
2,067 Views

@marty the only problem i am facing now is that if i run the application for quite a long time then it suddenly appears to crash..
Dont know why this crash is happening also it happens only a few times not a consistent crash like 2 out of 10 times it crashes.. 

So if you can say anything about it , it would be very helpful..

Thanks...

0 Kudos
MartyG
Honored Contributor III
2,067 Views

You are not the only person who has had this problem.  Late last year there was a poster on this forum who wanted to make a RealSense app that would run for three days, but after a while performance started to decline.

I have come across something similar myself.  I have had many times where the performance is great at first and then starts to get jerky and more unresponsive.  I spent a lot of time making changes to my project because I thought it was something I had done wrong when I made an earlier change to something.  It was only recently that I realized that the deterioration happened whether I made changes or not.  

Ironically, all those changes I made probably helped me to make better RealSense tech in Unity.  :)

Now what I do is reboot the PC as soon as the project becomes more difficult to control and that fixes the problem and restores smooth movement.

The symptoms would suggest either that the camera uses up a lot of memory when doing certain applications (I use a lot of simultaneous hand and face tracking and muscle / fat simulation in my game avatar) or there is what is known as a "memory leak" in Unity or the RealSense camera's library files that causes a decline as time passes. 

Edit: I just remembered something I read recently about Unity and memory in a game developer's blog.  He claimed that once something loads into memory in Unity then it stays there even if you destroy the object unless you use scripting to "unload" it from memory.  He recommended using memory management strategies to enhance the performance of Unity projects.  

Edit 2: I tracked the article down.

http://www.gamasutra.com/blogs/WendelinReich/20131109/203841/C_Memory_Management_for_Unity_Developers_part_1_of_3.php

0 Kudos
daflippers
Beginner
2,067 Views

Just to state the obvious....

Start Task Manager and check the resources used by your application...wait....wait...wait..check the resources used are the same as before.  If you are using more memory you have a memory leak.

David

0 Kudos
MartyG
Honored Contributor III
2,067 Views

I remember using Task Manager when developing the particle stream emission systems for my game (which were used to generate a sunset effect and a light halo around the moon).  When the particle emitters were running, the game would run okay for a while and then start grinding to a halt.  The task manager said that 99% of the CPU's capacity was being used while the particles were running, which was insane.  When I disabled the emitters, CPU usage dropped to 5%.

This was on a 3rd Generation Intel budget CPU.  Once I upgraded to an Intel Core i3 4th Gen CPU, I was able to run all the emitters simultaneously with only 3% CPU usage, so the age of chip architecture also seems to be a factor in performance.  Although right now, Unity is using 47% of my memory capacity when my game is running even with the Core CPU! 

Edit: I did some memory usage tests with my game.  I turned off the particle emitters and memory usage fell from 47% to 42%.  I turned off the avatar, which uses multiple TrackingAction scripts simultaneously, and usage dropped to 40% (so it seems the camera doesn't put much strain on the memory).  Finally, I disabled all the light sources in the game (of which there are probably about 50) and memory dropped to 36%.  It remained at 36% even in editor mode when nothing was actively running.

So even after all the particles and scripts were switched off, there was still something in Unity that was causing a high drain on memory.  Definitely something I'll do follow up research on sometime to see what optimizations I can make before the game comes out.

0 Kudos
daflippers
Beginner
2,067 Views

It sounds like your particle emitter CPU usage benefitted from running on different core(s) to other processes. 

There is a difference between memory use and memory leak.  If you have 90% memory use when started and 90% after 2 hours then that is ok.  If you have 10% memory use when started and 30% after 2 hours you probably have a memory leak and eventually your computer will crash.

David

0 Kudos
MartyG
Honored Contributor III
2,067 Views

*nods about usage vs leak*  This subject is a lot more interesting than you'd think it would be!.   / geek

I did a reboot of my PC and ran Unity again and it started at 27% in editor mode, as opposed to the 36% usage before the reboot.  When I ran my app for the first time, usage jumped to 31%, then stayed at that level no matter how many times I re-ran the app and waved my hands in front of the camera during the next few minutes (not enough time for a leak to show up).  Which would give credence to the memory blogger's claim that once Unity loads something into memory (like when an app is run), it stays there.

Oh, the memory usage has gone up from 31% to 35% in the 10 minutes I was sitting here writing this without being in the Unity window.  :)

Anyway, like I said, it's a topic I'll definitely take another look at one day, especially as I still have a lot to add to my app yet and so it'll become increasingly important to manage memory well.

0 Kudos
Vidyasagar_MSC
Innovator
2,067 Views

That's a very good test Marty. It also depends on your processor, RAM and other applications running on your system.

0 Kudos
Akshay_A_
Beginner
2,067 Views

@Marty @daflippers Thanks both of you for your suggestions...

Would definitely check the memory issue...and post my result regarding it..

0 Kudos
Reply