Comments (6)
Hi @Bobbyjoness,
Thanks using Jumper. And well, thanks for bringing this up.
Actually, you are somehow right. Jumper uses memory in order to represent the grid and nodes. And well, the amount of memory being used scales (exponentially...?) with the map size.
Thing is, I never wanted to dig much more in solutions to reduce the amount of memory used for one simple reason, it makes the code much more cleaner, and easier to maintain. And very convenient to me, as-is.
But suggestions are welcome. See, I am not at all proficient in LuaJIT and ffi structs (since I haven't used it). Can you please explain in greater details what would be the benefit of offering support for ffit structs ? I might look into this direction, if promising.
from jumper.
FFI structs use way less memory than a lua table. It's basically c structs. A 2d array of structs would use way memory. I'm not sure but maybe even a 2d array of ints/floats can be used. They don't have the overhead of a lua table.
from jumper.
I know its the holidays but if you want I can help work on this issue now and make a PR. I just need to know what route you want to go to optimize the memory. This is really a critical issue for me because currently in my project it is using over 1gb of memory for a line of a distance 2000 with a node at each pixel. This is very important because there is a bug in luajit causing memory to be maxed out at 1gb on Linux and 2 on windows/osx.
A good example of ffi use to reduce memory usage can be found here https://github.com/excessive/cpml/blob/refactor/modules/vec2.lua
Just the one line that uses structs makes it use less than half the memory. Possibly the same can be done for the node class
from jumper.
I have been looking at the code for the node class and the way it is used seems messy. This could be just my preference but it does not use getters and setters for all the fields it can have. This is an issue because for me to change the way node works I have to dig through all the code to find out what data the node class holds and how I could optimize it to use less memory.
from jumper.
Bobbyjoness@1cc2b53
I made a commit to my fork that will make the Node object utilize ffi structs. I can not make a PR because I had to break things to get this to work. Namely clearance. I did not know what the clearance table holds so I couldn't figure out the best way to represent it in a struct
from jumper.
@Bobbyjoness I tested your optimization and it does not work reliable. Using the ASTAR algorithm it crashed after the calculation of one path. Using another algorithm just didn't work due to memory access errors.
Error: /libs/jumper/core/node.lua:98: cannot convert 'nil' to 'float'
stack traceback:
[string "boot.lua"]:637: in function '__newindex'
/libs/jumper/core/node.lua:98: in function 'reset'
/libs/jumper/pathfinder.lua:359: in function 'reset'
/libs/jumper/pathfinder.lua:340: in function 'getPath'
/classes/misc/PathFinder.lua:20: in function 'findPath'
main.lua:67: in function 'update'
[string "boot.lua"]:509: in function <[string "boot.lua"]:493>
[C]: in function 'xpcall'
from jumper.
Related Issues (20)
- Replace ThetaStar with Lazy ThetAstar
- Add search algorithm : SPFA
- Add search algorithm : Breadth-First Search
- (dis)allow corner crossing in diagonal mode HOT 1
- Remove tunnelling
- Add path:shift()? HOT 3
- Attempt to call method 'getX' (a nil value) HOT 6
- Cannot build due to error in lookuptable.lua HOT 3
- Invalid or unreachable location HOT 3
- regenerate new path HOT 1
- 3D pathfinding with Jumper? HOT 2
- bug with JPS and ORTHOGONAL mode? HOT 4
- direction dependent walkability
- Syntax error in jumper/core/lookuptable.lua#L1 HOT 2
- Contributor needed? HOT 1
- isOutOfRange not defined - accesses an undeclared global
- node.x and node.y are nil HOT 2
- y and x axis reversed HOT 4
- Couldn't calculate path in a dynamic grid
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 jumper.