Comments (3)
Found some useful info here:
JavaScript, specifically ECMA-262 Edition 5.1, does not support finalizers or weak references with callbacks. Thus, JavaScript code must explicitly delete any C++ object handles it has received. Otherwise the Emscripten heap will grow indefinitely.
With that in mind, I realized that I was creating new b2Vec2
instances, but never destroying the original one. I'm so used to letting the JavaScript garbage collector do that for me.
So instead of creating a new b2Vec
on the last line, I re-used the one that already exists:
velocity.set_x(x);
velocity.set_y(y);
this.body.SetLinearVelocity( velocity, this.body.GetPosition() );
Perfect!
from box2d.js.
But is it possible to delete from Box2D the references we no longer need? because reusing is dangerous, I dont know if the reference I passed to box2D is being used internally so any changes could affect existing objects on the scene.
I guess I could check if the functions use copy, reference or pointer for every call, but maybe there is an easier way to free memory.
from box2d.js.
destroy
should free the C++ side of things.
On Thu, Jul 18, 2013 at 6:10 AM, jagenjo [email protected] wrote:
But it is possible to delete the references we no longer need? because
reusing is dangerous, I dont know if the reference I passed to box2D is
being used internally so any changes could affect existing objects on the
scene.β
Reply to this email directly or view it on GitHubhttps://github.com//issues/27#issuecomment-21181935
.
from box2d.js.
Related Issues (20)
- b2Vec2 won't free HOT 2
- Unable to build latest on macOS Mojave with [email protected] HOT 5
- High Gravity jitter HOT 1
- missing runtime methods for allocating arrays HOT 4
- box2d.wasm.html test faild with [email protected] build HOT 2
- is there typescript declaration file (d.ts) for this project? HOT 2
- Box2d 2.4.0
- Box2D 2.4.0 HOT 8
- Node server side implementation
- How does this work with webpack? HOT 1
- May I ask why the calculation results are different on the ios and android platforms HOT 2
- vue how to use it
- vue hao to use it
- why is not show?
- why now show debugdraw
- could i have more simple demos about the box2djs οΌand where can i see the API about box2djs
- How to build? I want to build the debug version of javascript file
- Position not getting what is set
- Uncaught (in promise) cannot construct a b2Draw, no constructor in IDL
- Cannot SetTarget of b2MouseJoint
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 box2d.js.