Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 2019 22:45
    eolivelli commented #4914
  • Jan 31 2019 22:07
    samsartor starred google/flatbuffers
  • Jan 31 2019 21:28
    marang starred google/flatbuffers
  • Jan 31 2019 20:51
    thyrlian starred google/flatbuffers
  • Jan 31 2019 19:19
    harshshah903 commented #5144
  • Jan 31 2019 19:19
    harshshah903 commented #5144
  • Jan 31 2019 18:56
    aardappel commented #4914
  • Jan 31 2019 18:54
    aardappel commented #5144
  • Jan 31 2019 18:51
    aardappel commented #5141
  • Jan 31 2019 18:51
    aardappel commented #5145
  • Jan 31 2019 18:51
    krojew commented #5142
  • Jan 31 2019 18:49
    krojew commented #5142
  • Jan 31 2019 18:48
    gabyx edited #5142
  • Jan 31 2019 18:48
    gabyx edited #5142
  • Jan 31 2019 18:47
    gabyx commented #5142
  • Jan 31 2019 18:47
    aardappel commented #5002
  • Jan 31 2019 18:43
    gabyx commented #5142
  • Jan 31 2019 18:43
    krojew commented #5142
  • Jan 31 2019 18:43
    aardappel commented #5143
  • Jan 31 2019 18:42
    gabyx commented #5142
Tsingson
@tsingson
ok, i found it.
pavanbadugu
@pavanbadugu
does flatbuffer grpc support javascript
Wouter van Oortmerssen
@aardappel
not yet
Tsingson
@tsingson

@aardappel about reflect.fbs , should v add a field " attributes:[KeyValue]; " like this :

table Schema {
    objects:[Object] (required);    // Sorted.
    enums:[Enum] (required);        // Sorted.
    file_ident:string;
    file_ext:string;
    root_table:Object;
    services:[Service];             // Sorted.
     attributes:[KeyValue];         //  add this one 
}

i through is good for me to write go verifier.

Wouter van Oortmerssen
@aardappel
@tsingson yup you can add that if you want
Tsingson
@tsingson
@aardappel cool, let's work it out.
Tsingson
@tsingson
how to avoid memory leaks in
```

std::string field_name_camel = MakeCamel(field.name);

change to

auto field_name_camel = MakeCamel(field.name);

???

Wouter van Oortmerssen
@aardappel
neither generates a memory leak.. strings are copied
Tsingson
@tsingson
https://travis-ci.org/github/google/flatbuffers/jobs/673953429 report memory leaks
/flatbuffers/src/idl_gen_go.cpp:1750
    #2 0x55e7fdeee6b2 in flatbuffers::go::GoGenerator::generate() /flatbuffers/src/idl_gen_go.cpp:100
    #3 0x55e7fdeea920 in flatbuffers::GenerateGo(flatbuffers::Parser const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /flatbuffers/src/idl_gen_go.cpp:1835
    #4 0x55e7fe1c2cf0 in flatbuffers::FlatCompiler::Compile(int, char const**) /flatbuffers/src/flatc.cpp:507
    #5 0x55e7fe1cf86a in main /flatbuffers/src/flatc_main.cpp:122
    #6 0x7f7abd58609a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
Big Jake
@JakeSays
@tsingson those leaks are in the compiler
even if they truly are leaks, it doesn't matter
it's probably due to some missing cleanup, and it's only 480 bytes
Tsingson
@tsingson
@JakeSays thanks.
look like i need learn more about modern c++
Wouter van Oortmerssen
@aardappel
The stacktrace in that log points to new being called on something in SaveType, I'd look there.
and yes, memory leaks should be cleaned up
MikkelFJ
@mikkelfj
@tsingson the string type uses a copy constructor and it isn’t particularly modern since it has existed since around 1990. The auto is more recent but just means you don’t have to specify the type explicitly, it doesn’t change the behaviour of the type compared to writing it out in full. Strings can copy, but usually they will reference count memory in a shared memory block and only copy if one is modified. Deallocation of course happens when the variable goes out of scope - either by decrementing a reference count or deallocating non-shared memory, or deallocating when the counter reaches zero.
Tsingson
@tsingson

@mikkelfj thanks for detail .

@aardappel can i use std::auto_ptr for new Namespace() ........

Tsingson
@tsingson
    // fix  miss name space issue
    Namespace *dns;
    if ((parser_.root_struct_def_) &&
        (def.defined_namespace->components.empty())) {
      dns = new Namespace();
      dns->components.push_back(parser_.root_struct_def_->name);
    } else {
      dns = def.defined_namespace;
    }

    Namespace &ns = go_namespace_.components.empty() ? *dns : go_namespace_;
this is OK ??
Tsingson
@tsingson
look dns = new Namespace(); in if block but it use out of if / else block , it's make memory leaks
Wouter van Oortmerssen
@aardappel
@mikkelfj pretty much no implementation of std::string does refc (cow) anymore.. the gnu implementation stopped doing that a long time ago. They are all "small object optimization" based nowadays.
MikkelFJ
@mikkelfj
Good to hear, I also wouldn’t recommend it.
Wouter van Oortmerssen
@aardappel
@tsingson there is a variable in Parser that holds all namespaces, that's where you should add it for auto cleanup.
MikkelFJ
@mikkelfj
Lua, which is different, also added small object optimisations to avoid GC in the common case.
Wouter van Oortmerssen
@aardappel
nice
for strings or?
MikkelFJ
@mikkelfj
yes
Wouter van Oortmerssen
@aardappel
and the "small object" is stored in-line in Lua tables?
MikkelFJ
@mikkelfj
I’m also working on something similar for typed Javascript-alike to C, but I’m not currently doing small objects, because it adds an extra test and complication, but I might do it.
Wouter van Oortmerssen
@aardappel
you'
're implementing a new language? what for?
MikkelFJ
@mikkelfj
I don’t recall exactly if it points to special memory or it is within the lua variable type. I did read the code carefully. But the main takeaway is that it is non-shared and copied aggressively. Basic small strings are a separate type, except for semantics.
I’m working on hiearchical state charts in SCXML. The action language can be anything, but there is a standard for Javascript case. Almost all test cases can be handled by a subset of Javascript which also happens to be an efficient expression language. So no prototype stuff etc. and only known classes with known members.
I did post some sample code here once - you saw it.
I also have a much more heavy duty GC for another project, but I avoid it for portability. That leaves some trade-offs. I can easily port to that when available. That GC has multiple generations with incremental page by page scans and is quite fast. I use it track distributed links between state machines or other actor objects.
Wouter van Oortmerssen
@aardappel
ahh ok
crazy :)
MikkelFJ
@mikkelfj
yes
MikkelFJ
@mikkelfj
I once had a convention of many thousands of dining philosphers seated a different tables to test concurrent concurrency and garbage collection. It was quite amazing to see it spit out a million chop stick passes without breaking a sweat.
Wouter van Oortmerssen
@aardappel
haha nice
classical test :)
Tsingson
@tsingson
@aardappel
this one ?
```
Namespace *Parser::UniqueNamespace(Namespace *ns) {
  for (auto it = namespaces_.begin(); it != namespaces_.end(); ++it) {
    if (ns->components == (*it)->components) {
      delete ns;
      return *it;
    }
  }
  namespaces_.push_back(ns);
  return ns;
}
this func clean up ?
Tsingson
@tsingson
memory leaks bug is fixed.
pavanbadugu
@pavanbadugu
can anyone help me on this
a,b are tables
c is a table in which a,b are fields
so i got the a flatbuffer data and b flatbuffer data which are loader seperately from file so now i need to construct a flatbuffer for c using .. is there any way just for copy raw bytes to flatbuffer and construct c table any api's for c++
MikkelFJ
@mikkelfj
No you cannot trivially do that in C++ as far as I know. You may be able to use the object API which is slower, but I am not familiar with that. For C, there is a clone method which can copy tables from other sources into a new buffer - it will do what you want, but it is still not simple block copy - each table field is copied recursively into the the new buffer.
pavanbadugu
@pavanbadugu
oh ok thanks
MikkelFJ
@mikkelfj
You can, however, store a and b as nested buffers if that is acceptable to you. That will allow storing each sub-buffer directly as a blob. It requires a schema change.
Normally I’d not recommend that, but it depends on the circumstances.