Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Memory errors using Tv Engine  (Read 9758 times)
harikumar001
Customers
Community Member
*****
Posts: 65


« on: February 08, 2011, 09:40:29 AM »

Hey all,

My application is giving me errors which I am not able to figure out. The error is reported from different lines at different times. I have a camera which can move around in a 3d room, just like a FPS player cam.

As I move the camera around in my room the view freezes and an exception occurs. .NET reports the "Attempted to read or write memory exception". There is no fixed time at which the exception occurs or a fixed position of the cam which causes the exception. It can happen anytime. In some cases the view freezes and in some cases a black screen comes up. The funny thing is that the line causing the exception is different on different occasions. I mostly get error from the following lines:

TV.RenderToScreen()
TV.Clear()

Any help would be much appreciated.

Regards

Logged
serial
Customers
Community Member
*****
Posts: 380


« Reply #1 on: February 08, 2011, 09:57:53 AM »

You are going to have to give us more detail than that...but are you deleting objects at runtime?
Logged
scottpipper
Customers
Community Member
*****
Posts: 82


« Reply #2 on: February 08, 2011, 11:04:09 AM »

Are you using Multithreading?
Logged
harikumar001
Customers
Community Member
*****
Posts: 65


« Reply #3 on: February 08, 2011, 12:05:21 PM »

Thank you scottpipper and serial for the prompt response

I am not using multi-threading in my application.

Can deleting objects at runtime cause such an issue?

Briefly, this is what my application does:
- User draws a 2d version of a room using 2d lines
- The same is converted to 3D (I use meshes with AddVertex to create walls) at runtime with the click of a button
- The user can switch back to 2D view, in which case I clear all the 3d mesh data and TV Variables
- If I click on the button to go to 3d mode again, my application reinitializes all TV variables and 3D view comes on. In the 3D view I can move around in the 3d space. Then all of a sudden after some random amount of time I get the exception mentioned above.

Note: There are no other meshes in the room other than my walls.

Regards
Logged
AriusEso
Customers
Community Member
*****
Posts: 940

Esoteric


« Reply #4 on: February 08, 2011, 12:10:56 PM »


Can deleting objects at runtime cause such an issue?


If you then go on to call one of those objects, yes, of course.
Logged

-...-

scottpipper
Customers
Community Member
*****
Posts: 82


« Reply #5 on: February 08, 2011, 12:20:26 PM »

Arius is right, trying to render or getting parameters on a deleted or unexisting object causes random errors on random parts of the code, try to avoid renderall commands, as sometimes the unload on the Graphics card is not instantly done, also, reinitializing TV objects as tvscene or tvengine a lot of times can cause that.
Logged
tedlin01
Customers
Community Member
*****
Posts: 143


WWW
« Reply #6 on: February 09, 2011, 07:12:40 AM »

Yeah, it seems like if your trying to use a pointer that is uninitialized/null or deleted. The only way of finding it that I know of is to keep commenting out parts of your code and running the app to see if the error still occurs. I had this hassle sometimes when declaring arrays the wrong way or using uninitialized(NULL) pointers.

I think that the reason for the errors being random is because you corrupt some bytes of the memory and it wont crash until some other function is trying to make use of those bytes.

Heres an example that causes that random crashes:

// This is the correct way of doing it
//cTV_COLLISIONRESULT * collisionresult = new cTV_COLLISIONRESULT[iSize];

// This is wrong way because if more then 5 collisions accurs the memory will run out of the scope
cTV_COLLISIONRESULT collisionresult[5];

m_pScene->MousePickEx((int)m_xLastMouse.x, (int)m_xLastMouse.y, collisionresult, cTV_OBJECT_ALL, cTV_TESTTYPE_BOUNDINGBOX, &iSize );
« Last Edit: February 09, 2011, 07:19:26 AM by tedlin01 » Logged

Dimple
Community Member
*
Posts: 643


« Reply #7 on: February 09, 2011, 04:36:10 PM »

Wink

@tedlin01,

Is the MousePickEx line a correct version or bad?  Just curious!

 
Logged

Using VB.NET, TV3D 6.5, Win 7
~~~~~~~~~~~~~~~~~~~~~~~

"Know how to ask. There is nothing more difficult for some people, nor for others, easier."

- Baltasar Gracian
serial
Customers
Community Member
*****
Posts: 380


« Reply #8 on: February 10, 2011, 12:08:03 AM »

Its a line of code that will work until you have more than 5 collisions then it will give you a memory error.
Logged
Dimple
Community Member
*
Posts: 643


« Reply #9 on: February 10, 2011, 05:12:56 PM »

 Smiley

My bad, I didn't look close enough.  I thought he was showing three different examples, not just the cause of his particular problem.
 
Logged

Using VB.NET, TV3D 6.5, Win 7
~~~~~~~~~~~~~~~~~~~~~~~

"Know how to ask. There is nothing more difficult for some people, nor for others, easier."

- Baltasar Gracian
harikumar001
Customers
Community Member
*****
Posts: 65


« Reply #10 on: February 18, 2011, 12:40:18 AM »

Hey Guys,

Thanks for the help. Appreciate it.

I actually found that reinitializing TV Engine and scene was causing the problem.

Every time I changed modes from 3D to 2D the tvengine variable was disposed and every time I changed from 2D to 3D the engine was initialized using the new keyword. It should be working correctly since every time I dispose the variable and create a new instance. But for some reason its giving errors.

I have changed my code so that TVengine and Scene is initialized only once during the life of the application. Now it works without errors.

Logged
ZaPPZion
Moderator
Community Member
*****
Posts: 571


« Reply #11 on: February 18, 2011, 04:39:59 AM »

Yea, the TVEngine is supposed to be some weird sort of singleton that can only be instanced once. It's expected behavior, though not that nice behavior Tongue
Logged

Check out my website: www.bartkuipers.com
AriusEso
Customers
Community Member
*****
Posts: 940

Esoteric


« Reply #12 on: February 18, 2011, 09:05:38 AM »

It's not weird and the behaviour is standard.
Logged

-...-

Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks