memory leak
This commit is contained in:
parent
6e86bec138
commit
ea026f1265
|
@ -48,7 +48,6 @@ namespace carla {
|
|||
if (!worldConnected())
|
||||
return false;
|
||||
readed = _pimpl->communication.tryReadEpisodeStart(startIndex, endIndex);
|
||||
std::cout << "Episode Start: " << readed << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -63,7 +62,6 @@ namespace carla {
|
|||
if (!worldConnected())
|
||||
return false;
|
||||
newEpisode = _pimpl->communication.tryReadRequestNewEpisode();
|
||||
std::cout << "New Episode Request: " << newEpisode << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -79,8 +77,6 @@ namespace carla {
|
|||
if (!worldConnected())
|
||||
return false;
|
||||
_pimpl->communication.sendScene(values);
|
||||
|
||||
std::cout << "Send scene values" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -88,9 +84,6 @@ namespace carla {
|
|||
if (!worldConnected())
|
||||
return false;
|
||||
_pimpl->communication.sendReset();
|
||||
|
||||
std::cout << "Send end reset" << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace server {
|
|||
std::cerr << "CarlaConnection - TCP Server: " << text << ": " << errorCode.message() << std::endl;
|
||||
}
|
||||
|
||||
|
||||
// This is the thread that sends a string over the TCP socket.
|
||||
static void serverWorkerThread(
|
||||
TCPServer &server,
|
||||
|
@ -48,12 +49,8 @@ namespace server {
|
|||
}
|
||||
}
|
||||
|
||||
//TODO:
|
||||
// Sortida amb google protocol
|
||||
// This is the thread that listens for string over the TCP socket.
|
||||
static std::unique_ptr<std::string> clientWorkerThread(TCPServer &server, thread::AsyncWriterJobQueue<std::string> &thr) {
|
||||
//if (!server.Connected()) server.AcceptSocket();
|
||||
|
||||
auto message = std::make_unique<std::string>();
|
||||
bool success = false;
|
||||
|
||||
|
@ -80,7 +77,7 @@ namespace server {
|
|||
return message;
|
||||
}
|
||||
|
||||
// This is the thread that listens & sends a string over the TCP world socket.
|
||||
// This is the thread that listens a string over the TCP world socket.
|
||||
static std::unique_ptr<std::string> worldReceiveThread(TCPServer &server, thread::AsyncReadWriteJobQueue<std::string, std::string> &thr) {
|
||||
auto message = std::make_unique<std::string>();
|
||||
bool success = false;
|
||||
|
@ -107,6 +104,7 @@ namespace server {
|
|||
return message;
|
||||
}
|
||||
|
||||
// This is the thread that sends a string over the TCP world socket.
|
||||
static void worldSendThread(TCPServer &server, thread::AsyncReadWriteJobQueue<std::string, std::string> &thr, const std::string &message) {
|
||||
if (!thr.getRestart()) {
|
||||
TCPServer::error_code error;
|
||||
|
@ -222,11 +220,6 @@ namespace server {
|
|||
|
||||
void CarlaCommunication::sendScene(const Scene_Values &values) {
|
||||
|
||||
// Protobuf produces a segmentation fault in the destructor of the Scene
|
||||
// when called from Unreal Engine in Linux. As a workaround, we added this
|
||||
// cute memory leak.
|
||||
/// @todo #10 Fix the memory leak!
|
||||
|
||||
Scene scene;
|
||||
_proto->LoadScene(scene, values);
|
||||
|
||||
|
|
|
@ -48,8 +48,8 @@ namespace server {
|
|||
|
||||
|
||||
struct img_encode{
|
||||
char* buffer;
|
||||
size_t size;
|
||||
char* buffer;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
struct TPngDestructor {
|
||||
|
@ -66,7 +66,8 @@ namespace server {
|
|||
void loadPNGData(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
/* with libpng15 next line causes pointer deference error; use libpng12 */
|
||||
img_encode* p=(img_encode*)png_get_io_ptr(png_ptr); /* was png_ptr->io_ptr */
|
||||
img_encode* p = (img_encode*) png_get_io_ptr(png_ptr);
|
||||
|
||||
size_t nsize = p->size + length;
|
||||
|
||||
/* allocate or grow buffer */
|
||||
|
@ -81,8 +82,6 @@ namespace server {
|
|||
/* copy new bytes to end of buffer */
|
||||
memcpy(p->buffer + p->size, data, length);
|
||||
p->size += length;
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool LoadBitmap (bitmap_t &bitmap, const Image &image_info){
|
||||
|
@ -232,7 +231,7 @@ static bool getPNGImages(const std::vector<Image> &images, Reward &rwd){
|
|||
break;
|
||||
}
|
||||
|
||||
free (compressedImage.buffer);
|
||||
delete compressedImage.buffer;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -115,11 +115,14 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
carla::Scene_Values sceneValues;
|
||||
|
||||
sceneValues.possible_positions.push_back({0.0f, 0.0f});
|
||||
sceneValues.possible_positions.push_back({1.0f, 2.0f});
|
||||
sceneValues.possible_positions.push_back({3.0f, 4.0f});
|
||||
for (int i = 0; i < 1; ++i){
|
||||
sceneValues.possible_positions.push_back({0.0f, 0.0f});
|
||||
sceneValues.possible_positions.push_back({1.0f, 2.0f});
|
||||
sceneValues.possible_positions.push_back({3.0f, 4.0f});
|
||||
}
|
||||
|
||||
const std::array<float, 16u> pMatrix = {{ 10.0 }};
|
||||
sceneValues.projection_matrices.push_back(pMatrix);
|
||||
for (int i = 0; i < 100; ++i) sceneValues.projection_matrices.push_back(pMatrix);
|
||||
|
||||
if (!server.sendSceneValues(sceneValues)) {
|
||||
std::cerr << "ERROR while sending SceneValues" << std::endl;
|
||||
|
@ -159,15 +162,10 @@ int main(int argc, char *argv[]) {
|
|||
break;
|
||||
}
|
||||
|
||||
std::cout << "Waiting Episode Start" << std::endl;
|
||||
|
||||
uint32_t startPoint, endPoint;
|
||||
bool error = false, readed = false;
|
||||
do {
|
||||
|
||||
std::cout << "Try read episode Start: ";
|
||||
error = !server.tryReadEpisodeStart(startPoint, endPoint, readed);
|
||||
std::cout << error << std::endl;
|
||||
|
||||
} while (!readed && !error);
|
||||
|
||||
|
|
Loading…
Reference in New Issue